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. Set pixels of RowWrapPolicy::WrapLongRows
QtWS25 Last Chance

Set pixels of RowWrapPolicy::WrapLongRows

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.6k Views
  • 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.
  • E Offline
    E Offline
    ephe
    wrote on last edited by
    #1

    I've got a QFormLayout, and I would like to wrap the rows.
    I'm sorry, I'm not that familiar with the layouts.

    Is it possible to set a fixed size for the first row of the QFormLayout? E.g. that the labels should not get wider than 100 pixels?

    Or is it possible to set the pixels of the RowWrapPolicy::WrapLongRows, so that it wraps the row when the text is wider than 100 pixels?

    1 Reply Last reply
    0
    • B Offline
      B Offline
      broadpeak
      wrote on last edited by
      #2

      Something like this?:
      @
      QFormLayout *formLayout = new QFormLayout;
      formLayout->addRow(tr("&Name:"), nameLineEdit);
      ...
      formLayout->setRowWrapPolicy(QFormLayout::WrapLongRows);
      setLayout(formLayout);
      @
      or:

      You have to use sizeHint() with QSizePolicy::Maximum.
      Probably this is better, because you can set it to max 100px.

      [edit, please use @ tags, Eddy]

      1 Reply Last reply
      0
      • E Offline
        E Offline
        ephe
        wrote on last edited by
        #3

        Thank you for your answer!
        I have tried @formLayout->setRowWrapPolicy(QFormLayout::WrapLongRows);@ already, but then it only wraps when the whole row is filled by text.

        I'm sorry, but how can I set the sizeHint()? I would like the first column to be fixed and the second column should expand. Or for example set the ratio of the width of the columns (e.g. 1:2).

        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