PDA

View Full Version : Why is QDialog::setFont() inherited by some widgets and not others



malch
8th March 2016, 19:09
I created a QDialog derived class in QtCreator. In Designer, I added various widgets including QPushButton, QLabel and QLineEdit items.

In the class constructor, I added:



setFont(myFont);


The selected font is correctly inherited by the QBushButtons. But it is NOT inherited by the QLabel or QLineEdit items. Why and how do I fix it?

d_stranz
9th March 2016, 16:34
If you are using Qt Designer to create your dialog UI, it is easier to set the font there. Open the UI file in Designer, click on the dialog (top level item) to select, then set the font. All the child widgets should inherit it, but you should check to make sure. The easiest is to set the font when first creating the dialog, then each new child widget is sure to inherit it.

If you do it at run time, you should set the font before you call setupUi().

I've never used "QBushButtons" so maybe there is something special about them. :rolleyes: