In this work, I will create a very simple Qt Application with a dummy button (inherite from QPushButton), start from Empty Qt Project.
Start QtCreator, click File -> New project or Project... on the top menu, Select Empty Qt Project under Project.
Fill in the Name (MyFirstWidget here) of your project and browse to the locate where to create your project on, and click Next
Then Finish.
Because what you created is a Empty Qt Project, only a dummy MyFirstWidget.pro will be created.
Create a main.cpp, click File -> New project or Project..., select C++ Source File under C++, and Click OK.
Fill in the Name of the source file, main, click Next, and then Finish.
Insert the following code in main.cpp
#include <QtGui>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget window;
window.resize(320, 240);
window.setWindowTitle("My First Widget");
window.show();
QPushButton *button = new QPushButton("Hello", &window);
button->move(100, 100);
button->show();
return app.exec();
}
Save All and Click the Run button (Green Arrow).
Up to now, we created a Qt application, with a no function button.
Labels
Dev. tools
(13)
how to
(10)
Internet of Things (IoT)
(1)
learn Qt
(1)
misc
(1)
misc.
(1)
mobile
(2)
news
(6)
OpenCV
(1)
OpenGL
(1)
QML
(1)
qml example
(40)
Qt
(2)
Qt Cloud
(1)
Qt Creator
(3)
Qt Creator Examples
(4)
Qt Enterprise Embedded
(1)
Qt Examples
(1)
Qt for Android
(5)
Qt for iOS
(2)
Qt for MCU
(1)
Qt news
(1)
Qt Quick
(3)
Qt Quick Control
(1)
Qt Quick Designer
(2)
QtQuick example
(14)
QtQuick.Controls examples
(13)
Ubuntu SDK
(1)
VirtualBox
(1)
WebEngine
(1)