开发者

How do you use dialog forms in Qt designer?

How d开发者_StackOverflow中文版o 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

How do you use dialog forms in Qt designer?

Click Create.

Can view code by Menu->Form->ViewCode

How do you use dialog forms in Qt designer?


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:

  1. Launch QtCreator, and from the menu bar (outside QtCreator), click on: File>New File or Project

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜