Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED] question starting up Qt development
I have a Kylix (c++) application I would like to recreate in Qt.
Currently I am just fooling around with the lovely! editor trying out sample etc.
However, I do have 4 question so far, that I hope someone might answer.
1) grey slots
I have chosen a widget as mainwindow
when in design mode, i select Change signals/slots
and they are all (slot/signals lists) grey in the Dialog.
Say I want to add code to the Show() slot.
How would I do that? (from designer)
(For a button it worked fine)
2) no help for std::vector and friends
Custom help files.
Sometimes I am a places where there is NO internet..
I noticed that for std::vector and such, there
is no help. (installed)
Does that exists/can be done ?
3) MainWindow types
a form can be any widget?
Coming from Kylix, a form would be a window type but
in Qt it is any widget without a parent?
4) Layout blues
make layouts use full area of a container.
I put a GroupBox on the "form"
then I put V layout inside that grpbox.
How would I make the VLayout always fill the entire
(client/content) area of the Groupbox even if it was resized?
TheBadger last edited by
1) First time I see this, not sure why this happens (I have never used this functionality). What do you want to do?
2) Qt has very good container classes of their own, which I would recommend you use in Qt applications. For std::vector you have QVector, std::map have QMap, and so on. These are portable and very well documented in the documentation (see "here":http://qt-project.org/doc/qt-5/containers.html for a list). My general advice is: If in a Qt application you use std::*, you are doing something wrong :)
3) Yes, I have some experience with what Kylix so you are correct. Any Qt Widget without a parent can be a "Form" and any Qt widget can be embedded inside any other Qt Widget (or at least from my understanding, perhaps there are cases where this is invalid).
4) There is a bit of understanding needed to do this from the designer. Basically each widget you add has a layout already, you juts need to enable it. By adding one, you end up with 2 (not really, but think of it in that way).
So to achieve what you want:
Add other widgets to your GroupBox, like a button and a label.
Click on the GroupBox you want to manage the layout
In the designer, at the top you will see a few buttons get enabled, normally their images are blue (one with 3 vertical lines, one with 3 horizontal lines, one with 2 columns with dots, etc). These are the layouts you can "enable" for the groupbox. Only one can be active, but you can toggle between them to see the effects.
So generally there is no need to add a new layout to most of the widgets since the layout buttons at the top will take you 99% of the way
Edit: Did not preview before posting, fixed a few formatting errors
TheBadger last edited by
To come back to 1) (sorry I skipped the last part of the question)
"Say I want to add code to the Show() slot.
How would I do that? (from designer)"
You should not click "Change signals/slots", rather click on "Go to slot..."
For the Show() slot, there is unfortunately no signal emitted to indicate that the widget got shown. Thus you can not create a slot for that using signals and slots.
Instead you need to implement the "void QWidget::showEvent(QShowEvent * event)" function in your derived class and handle the different events there ("link":http://qt-project.org/doc/qt-5/qwidget.html#showEvent).
To add to what Badger said:
The "change signal/slot" dialog is for letting the editor know what signals and slots are defined in the source file implementing that dialog. The gray ones are the builtin signals/slots of given class. After you add a signal/slot in that dialog you can use them to make a connection in the signal/slot editor window. This dialog does not create these signals or slots for you. You need to create them yourself in code.
The problem with help for standard containers is that there's no single implementation of the standard and the ones existing differ in completeness and conformance. Nevertheless you can still add a custom .qch file to the Qt Creator help system in the tools->options->help window. For example the cppreference.com page offers their documentation in Qt .qch format "here":http://en.cppreference.com/w/Cppreference:Archives. Some others are listed "here":http://qt-project.org/wiki/Qt_Creator_Documentation_Gallery
All above is true and in addition to widgets in Qt5 there's a new type QWindow that represents a window that can host widgets, QML, native controls, OpenGL surface and more.
Well it's not true that widget has a layout by default, but you can add one like Badger explained. The red rectangles that you can add from the widget box get translated to frames with layouts set, but they are not placed in a layout themselves, so for most uses are pointless. Use the layouts from the top toolbar or context menu.
Aha, I think what confused me is the
- (add) in signals/slot Dialog.
And the fact it show some slot/signals
even when not avaialble for the widget.
Some of the data structures are shared with other projects that will not
be Qtfied so I still need std::* sometimes.
Will use QContainers when possible as I assume it works better (with Qt) than std:: versions.
The links are perfect.
So using QWindow might be the best widget for window like widget.
Ill look it up.
Aha, add via rightclick, it uses all clientarea.
So one will start with this default layout and then insert other layout to
get the overall layout. I think I should read more about them
as they seem to battle me or I use them wrongly.
Trying to get 3 areas, where top area should always be 64 pix in H and w whole window.
Thank you both for answering.
Do I flag it as SOLVED/CLOSED and if yes, how ?
- (add) in signals/slot Dialog.
Just an additional correction, using the std library with Qt is not wrong at all. Take for example the QtAlgorithm stuff, most of them has been deprecated in Qt 5 in favor of std's version.
ok. that is good to know as I will be mixing it.
Also due to code reuse.
I just mentioned QWindow for completeness. If your app is gonna be widget based there's no need to use it, as the specialized widgets like QMainWindow or QDialog will give you much more functionality for free.
As for the layouts: Add three widgets(or frames/groupboxes). Place them in a vertical box layout. Select the top one and go to the properties. Change vertical size policy to fixed and then change minimum and maximum height to 64.
It sounds like a toolbar. If that's it then check out QMainWindow. You can add a QToolbar to it without such hassle.
To mark the thread as solved just prepend [SOLVED] to the title.
Ok, it did seem geared for using openGL, qml etc and im not sure i will need that. That said, it seems not to be so much hassle to replace it later if need be.
QMainWindow had predefined idea of layout so I though that using a clean widget would be better. Still just trying things out.
Its indeed like a Toolbar but with mixed widgets. I need unicode text, icon, buttons and drop down menus. All custom drawn and MUCH bigger than normal. Its not a normal desktop app (as such) but used for industrial machine and operated with a glove on a 19" touch screen.
Ahh I see QToolbar also accept other widgets. :)
It will be fullscreen with no decorations and Im still looking for what to use as screen/pages/windows as it seems any widget will do but I might use Dialogs this time for some operations.
ahh. the Fixed part was the key.
Thank you for your input!
ps. Its not clear to me how to edit the Title.
Sounds you should rather go with QML or QGraphicsView to have more control over your interface.
To edit the title, just edit your first post
Well, i did look at QML but I had the following concerns:
It said "no supported" when tried some javascrip in QML file in Designer.
In the designer, it seems that the design space has 0,0 in center which will drive me nuts. I want something like a form/window concept with fixed size and 0,0 in normal spot. I have like 40 screens/windows.
I already have a design with widgets (kylix) that has the look and function I would like to keep and QML seems so much another beast.
Since kylix uses Qt as backbone, I expect I can do the same.
That said I do not know this framework so any input is highly valued as what to use as foundation.
Currently I have
custom ownerdrawn button
ownerdrawn listbox, listbox that allows special edit control
special edit control that allows to edit with reduced keyboard. (no delete, backspace)
2 types of a graph type view.
ownerdraw combo box
overall, i need the controls do be bigger to allow touch input.
Touch is a simulated mouse, not multi touch.