Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFormLayout: Setting Font Size
Forum Updated to NodeBB v4.3 + New Features

QFormLayout: Setting Font Size

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 3.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    archibalduk
    wrote on last edited by
    #1

    I have a simple QFormLayout and have assigned some labels to the row fields like so:

    @labelSavedGameCreatedDate = new QLabel("n/a");
    labelSavedGameCreatedDate->setFont(QFont("MS Shell Dlg 2", 10));

    [...]

    ui->formSavedGameInfo->addRow(tr("Game Created"), labelSavedGameCreatedDate);@

    As you can see, I'm setting the font size of the labels in the fields so that they are size 10, a little larger than the default size 8. However, I'm not sure how to set the font size of the row labels themselves. I've been Googling and looking through the QFormLayout and QLayout documentation but cannot see anything which sets the font size of the row labels. Is this possible or is it always set to the default size of the operating system?

    Assuming it's not possible, I suppose I'll have to go with a QGridLayout instead - it's just that I like the simplicity of setting rows with QFormLayout.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome do devnet,

      You could use labelForField from QFormLayout and set your font on the returned widget.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        archibalduk
        wrote on last edited by
        #3

        Perfect! Thank you very much!

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You're welcome,

          Please update the thread's title to solved so other forum users may know a solution has been found :)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved