Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QT/PyQT best practice for using QT Designer

Tags:

qt

pyqt

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 fine tune behaviour of a QButton or QLineEdit ? Is it possible to add this custom widget to designer?

like image 774
pierocampanelli Avatar asked May 25 '10 14:05

pierocampanelli


1 Answers

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.
like image 134
Mihai Limbășan Avatar answered Sep 24 '22 03:09

Mihai Limbășan