About Qt Creator IDE UI - qt

Please look the image below , I want to know what are the components of the three regions?
I think:
A - is QToolBar + QAction
B - is QListView
C - I don't know what it is
Have you any examples to create Qt IDE style ?
Thanks.

You can use spy++ tool in the Microsoft Visual Studio ( any version )
That shows the class name of the window control by selected.
run spy++
click main toolbar -> log message
it shows a dialog
click search tool in top right and drag to the window control you want
see class name in the dialog.

Related

Workaround Qt bug Combobox dropdown appear behind window

Right now I have a small tool app that runs in the icon tray. When I click on the icon, the app goes into "windowstayontophint" mode. I added a Combo Box on this window. But when I click elsewhere on desktop, and then click the combo box, the drop down window goes to the back of the window. This seems to be a known bug as reported here:
https://bugreports.qt.io/browse/QTBUG-61804
Is there a workaround for this? I am using Qt 5.9.1.
EDIT: Add some code:
This in MainWindow constructor:
Qt::WindowFlags flags = this->windowFlags();
this->setWindowFlags(flags|Qt::WindowStaysOnTopHint);
Then I put a QComboBox in the mainwindow with preloaded items. First time click, the dropdown appears on top as normal. Then I click onn desktop and then back on the mainwindow and combobox. And drop down becomes at the back of mainwindow. CLick on the link above to see what I mean. The bug report also provide screenshot of what is happening.
Nobody want to put an answer, so I answer this myself.
ANSWER: Update to latest Qt.
It did not work for me because I was having trouble updating (noob here). What basically happened was that Selecting "Update" option on Maintenance Tool does not update SDK from 5.9.1 to 5.10.1. It only update certain things like Qt Creator.
I needed to choose "Add or remove Components" and then adding Qt 5.10.1, but only check the MinGW 32bit only. (Uncheck all others otherwise you need them (like android or other)).
Even after that, you also need to manually download CMake (get it from cmake.com) and set it in "Manage Kits" in Qt Creator.

QDockWidget form in Qt Creator Designer

I'm using Qt Creator 4.5.0 and am trying to create a QDockWidget that I could modify in the builtin designer (I do this all the time with QDialogs and QMainWindows, so this is the first time trying with a QDockWidget). But I'm having no luck with being able to add any widget elements of any kind to the QDockWidget.
Here are the steps I've taken
In the Projects tree on the left, right click on the project and select "Add New..."
In the window that pops up select "Qt" on the left side, then select "Qt Designer Form Class", then select "Choose"
On this page expand the section for "Widgets", then select "QDockWidget", then select "Next"
On this page give the class a name (for me it's "ImageFilesDockWidget"), then click "Next"
On this page select "Finish" to add the files to the project.
From here the "ImageFilesDockWidget.ui" file will automatically show up, so I tried to add some widgets to the view, but nothing would get added. For example, if I clicked and dragged a pushbutton into the center of the dockwidget, then it displayed a red circle with a line through it to indicate I couldn't add the item.
If anyone has run into this problem and knows how to make it work, then that'd be an immense help to me.
Thanks in advance.
update
Currently I'm able to use the designer to customize a standard QWidget object (call it "ImageFilesWidget.ui"). So at the moment my solution is to add a standard QDockWidget to my QMainWindow in the designer, then (still in the designer) I promote the dockWidgetContents from a standard QWidget to my ImageFilesWidget class.
It seems like the problem is when qtcreator 4.5 creates the dockwidgets ui file for you, it doesn't include the "dockWidgetContents" widget that is included in previous versions. Just manually put <widget class="QWidget" name="dockWidgetContents"/> under the "windowTitle" property of the dockwidget and you'll be able to add ui elements to it.

Qt creator - make a dynamic interface

I am working on a small UI with QT Creator and its drag-n'-drop tool (QT Designer). Everything was fine till I realized I had to make some widgets dynamic. For example, I have a checkbox and I want some button to appear only if this checkbox is checked by the user or I would like to change the appearance of another widget when the user clicks on some button.
Is it possible to do it only with QT Designer?
Yes, but it's very limited.
Qt designer have signal&slot editor. Yes, you can connect signal clicked(bool) to setVisible(bool) slot on button and make button visible only when checkbox is checked (see screenshot).
But when You need more complex dynamic interface (e.g. creating buttons), designed will not help You.

Launching new form by a button click in qt gui application?

I am trying upon some simple applications. I would like to know how to launch a new form by clicking a button from main window. Please explain this to me with a simple example.
QT already comes with a simple example on how to create and show different types of windows and dialogs. Take a look here: Window Flags Example
Also if you already have a main widow in your application, you can take a look how it's shown (main function in your main.cpp) for your project and use the same technique:
MainWindowTest *testWindow = new MainWindowTest();
testWindow->show();
If you need to show a modal dialog, use your dialog's exec() method:
Dialog *dialog = new Dialog();
dialog->exec();
hope this helps, regards

How do you use dialog forms in Qt designer?

How do you create and access dialog forms in Qt designer?
At the risk of pointing out the blisteringly obvious...
Qt Designer -> File -> New -> Dialog [with buttons/without buttons] -> Create.
You then drag widgets from the Widget Box into the dialog. (View -> Widget Box if you can't see it.)
If you want auto-sizing support, you drag a Layout into the Dialog, then drag your Widgets into the layout.
Qt Designer -> File -> New
Click Create.
Can view code by Menu->Form->ViewCode
Generally, you create a dialog form the same way you do other widgets in Qt designer. That is to say, create a new widget, and fill it with the widgets you want. You'll need to create code files to manage how the dialog works, of course.
To show the dialog, you should create an instance of the widget and show it. Generally, a widget that has no parent will be shown as a separate window. Alternately, if your widget inherits from QDialog, you can pass a parent but it will still show as a separate window.
Launching QtDesigner with QtCreator 3.6.1
QtCreator 3.6.1
Qt 5.6
OSX Yosemite 10.10.5
I installed Qt via:
qt-unified-mac-x64-2.0.2-2-online.dmg
The default installation directory was /Users/7stud/Qt. I found QtCreator.app at the top level of that directory.
I installed sip and then pyqt from source:
PyQt-gpl-5.5.1.tar.gz
as presented here: https://www.riverbankcomputing.com/software/pyqt/download5
To access QtDesigner:
Launch QtCreator, and from the menu bar (outside QtCreator), click on:
File>New File or Project
You will be presented with a New File or Project dialog window. In the Files And Classes section, select Qt. In the middle pane, select QtDesigner Form. Then click on the Choose button in the lower right corner.
You will be presented with a QtDesigner Form dialog window. Then you can select Main Window or Dialog with Buttons Bottom, etc. Then click on the Continue button in the lower right corner.
In the Location dialog window, use a name like mainwindow1.ui, and for the path you might want to step aside and create a directory called forms, e.g. $ mkdir /Users/7stud/qt_projects/forms, then enter that as the path.
Enter any other details and click on Done. That will land you in QtCreator with the Design button selected (which means you are in QtDesigner), and you will be able to drag and drop widgets onto your window.
To convert the .ui file to a .py file that you can import into your python program:
$ pyuic5 mainwindow1.ui -o mainwindow1.py
-o => output file (default is stdout)
That command converts the .ui file mainwindow1.ui to a .py file named mainwindow1.py.

Resources