Results 1 to 2 of 2

Thread: Why is QDialog::setFont() inherited by some widgets and not others

  1. #1
    Join Date
    Mar 2016
    Location
    California, USA
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Why is QDialog::setFont() inherited by some widgets and not others

    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:

    Qt Code:
    1. setFont(myFont);
    To copy to clipboard, switch view to plain text mode 

    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?

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Why is QDialog::setFont() inherited by some widgets and not others

    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.

Similar Threads

  1. Blocksignals for all widgets within a QDialog
    By muzzled in forum Qt Programming
    Replies: 4
    Last Post: 12th October 2011, 16:21
  2. QApplication::setFont working only for some widgets?
    By golanwe in forum Qt Programming
    Replies: 0
    Last Post: 13th January 2011, 17:47
  3. Inherited Properties on Custom Widgets
    By mbreier in forum Qt Programming
    Replies: 3
    Last Post: 30th April 2010, 07:30
  4. Signals from inherited widgets
    By pippo42 in forum Qt Programming
    Replies: 5
    Last Post: 25th February 2010, 09:47
  5. Replies: 2
    Last Post: 16th May 2008, 14:39

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.