QT/PyQT best practice for using QT Designer
What is your development approach with QT/PYQT and QT Designer ?
Are you doing this:- Put all components on the panel (without any layout) and arrange them
- Put components in layout (Align Vertically/Horizontally/Form/Grid)
- Generate UI file and start coding
how do you manage when you have custom widget ? For example when you have to f开发者_运维知识库ine tune behaviour of a QButton or QLineEdit ? Is it possible to add this custom widget to designer?
Answer to part of your question:
Yes, it's possible to add custom widgets to the designer. You have two alternatives:
- You can write a full-fledged designer plugin - see Creating Custom Widgets for Qt Designer for a full example.
- You can promote widgets - i.e., you pick an already existing widget that's similar in looks and/or functionality to the widget you'll be creating at runtime, you place the "mock" widget on the form, you right click it, and you "promote" it to the actual type of the final widget you'll be using. At runtime, the form parser will create your actual widget instead of the placeholder. See Using Custom Widgets with Qt Designer > Promoting Widgets for more details.
精彩评论