Evan Evan - 1 month ago 4x
C++ Question

writing a qt application in raw c++ (no qml)

I'm a c++ newbie, and have recently started messing around with GUIs.

I've made a windows application that works fine, but in addition to being a bit inconvenient at times, it frustrates me that it will only work on windows.

I'm trying qt, and after an hour of googling, and searching around their tutorials, I cant seem to find a way to write a program using raw c++ code (no qml or any stuff like that).

What I would want would be something like functions for displaying qt objects like:


If I'm being too general, it would be nice to know what I can specify before having this thread closed.


You should look at the widgets examples. http://doc.qt.io/qt-4.8/examples-widgets.html

In the few that I selected all the widgets are created natively in C++. For instance, in the windowflags example (http://doc.qt.io/qt-4.8/qt-widgets-windowflags-example.html). It shows how to make a button.

quitButton = new QPushButton("Button Name");
// Signal and slots are how QT handles it's callbacks
connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));

For layouts you need to look into the QT Layout options. I prefer to use designer to get a feel how the objects will look when placed, then usually write my own layout. Again from the example, to add the button to the GUI

QHBoxLayout *bottomLayout = new QHBoxLayout;
bottomLayout->addStretch(); // Fill entire area
bottomLayout->addWidget(quitButton);  // Place our button in that area
setLayout(bottomLayout);  // Push layout to main GUI object.