开发者

QT/PyQT best practice for using QT Designer

开发者 https://www.devze.com 2022-12-31 19:13 出处:网络
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

What is your development approach with QT/PYQT and QT Designer ?

Are you doing this:

  1. Put all components on the panel (without any layout) and arrange them
  2. Put components in layout (Align Vertically/Horizontally/Form/Grid)
  3. 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.
0

精彩评论

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