mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-05 08:45:25 +08:00
qt 6.5.1 original
This commit is contained in:
40
examples/dbus/remotecontrolledcar/controller/CMakeLists.txt
Normal file
40
examples/dbus/remotecontrolledcar/controller/CMakeLists.txt
Normal file
@ -0,0 +1,40 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
if(NOT DEFINED INSTALL_EXAMPLESDIR)
|
||||
set(INSTALL_EXAMPLESDIR "examples")
|
||||
endif()
|
||||
|
||||
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/dbus/remotecontrolledcar/controller")
|
||||
|
||||
set(controller_SRCS)
|
||||
qt_add_dbus_interface(controller_SRCS
|
||||
../common/car.xml
|
||||
car_interface
|
||||
)
|
||||
|
||||
qt_add_executable(controller
|
||||
controller.cpp controller.h controller.ui
|
||||
main.cpp
|
||||
${controller_SRCS}
|
||||
)
|
||||
|
||||
set_target_properties(controller PROPERTIES
|
||||
WIN32_EXECUTABLE TRUE
|
||||
MACOSX_BUNDLE TRUE
|
||||
)
|
||||
|
||||
target_link_libraries(controller PRIVATE
|
||||
Qt6::Core
|
||||
Qt6::DBus
|
||||
Qt6::Gui
|
||||
Qt6::Widgets
|
||||
)
|
||||
|
||||
install(TARGETS controller
|
||||
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
)
|
25
examples/dbus/remotecontrolledcar/controller/controller.cpp
Normal file
25
examples/dbus/remotecontrolledcar/controller/controller.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
#include "controller.h"
|
||||
|
||||
using org::example::Examples::CarInterface;
|
||||
|
||||
Controller::Controller(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
car = new CarInterface("org.example.CarExample", "/Car", QDBusConnection::sessionBus(), this);
|
||||
|
||||
connect(ui.accelerate, &QPushButton::clicked, car, &CarInterface::accelerate);
|
||||
connect(ui.decelerate, &QPushButton::clicked, car, &CarInterface::decelerate);
|
||||
connect(ui.left, &QPushButton::clicked, car, &CarInterface::turnLeft);
|
||||
connect(ui.right, &QPushButton::clicked, car, &CarInterface::turnRight);
|
||||
|
||||
startTimer(1000);
|
||||
}
|
||||
|
||||
void Controller::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
ui.label->setText(car->isValid() ? tr("connected") : tr("disconnected"));
|
||||
}
|
26
examples/dbus/remotecontrolledcar/controller/controller.h
Normal file
26
examples/dbus/remotecontrolledcar/controller/controller.h
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
#ifndef CONTROLLER_H
|
||||
#define CONTROLLER_H
|
||||
|
||||
#include "ui_controller.h"
|
||||
#include "car_interface.h"
|
||||
|
||||
class Controller : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Controller(QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *event) override;
|
||||
|
||||
private:
|
||||
Ui::Controller ui;
|
||||
org::example::Examples::CarInterface *car;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
13
examples/dbus/remotecontrolledcar/controller/controller.pro
Normal file
13
examples/dbus/remotecontrolledcar/controller/controller.pro
Normal file
@ -0,0 +1,13 @@
|
||||
QT += dbus widgets
|
||||
|
||||
DBUS_INTERFACES += ../common/car.xml
|
||||
FORMS += controller.ui
|
||||
HEADERS += controller.h
|
||||
SOURCES += main.cpp controller.cpp
|
||||
|
||||
# Work-around CI issue. Not needed in user code.
|
||||
CONFIG += no_batch
|
||||
|
||||
# install
|
||||
target.path = $$[QT_INSTALL_EXAMPLES]/dbus/remotecontrolledcar/controller
|
||||
INSTALLS += target
|
64
examples/dbus/remotecontrolledcar/controller/controller.ui
Normal file
64
examples/dbus/remotecontrolledcar/controller/controller.ui
Normal file
@ -0,0 +1,64 @@
|
||||
<ui version="4.0" >
|
||||
<class>Controller</class>
|
||||
<widget class="QWidget" name="Controller" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>255</width>
|
||||
<height>111</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Controller</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string>Controller</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" >
|
||||
<widget class="QPushButton" name="decelerate" >
|
||||
<property name="text" >
|
||||
<string>Decelerate</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QPushButton" name="accelerate" >
|
||||
<property name="text" >
|
||||
<string>Accelerate</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2" >
|
||||
<widget class="QPushButton" name="right" >
|
||||
<property name="text" >
|
||||
<string>Right</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QPushButton" name="left" >
|
||||
<property name="text" >
|
||||
<string>Left</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
15
examples/dbus/remotecontrolledcar/controller/main.cpp
Normal file
15
examples/dbus/remotecontrolledcar/controller/main.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
|
||||
#include "controller.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
Controller controller;
|
||||
controller.show();
|
||||
return app.exec();
|
||||
}
|
Reference in New Issue
Block a user