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. QLabel does not extend to full width of QFormLayout when wrapped
Forum Updated to NodeBB v4.3 + New Features

QLabel does not extend to full width of QFormLayout when wrapped

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 694 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.
  • M Offline
    M Offline
    Martin Burchell
    wrote on last edited by
    #1

    I have a PasswordEntryDialog class that inherits from QDialog. This consists of a text box with a label in a QFormLayout:

    PasswordEntryDialog::PasswordEntryDialog(const QString& text,
                                             const QString& title,
                                             QWidget* parent) :
        QDialog(parent)
    {
        setWindowTitle(title);
        setMinimumSize(uifunc::minimumSizeForTitle(this));
    
        auto prompt = new QLabel(text);
        prompt->setWordWrap(true);
    
        m_editor = new QLineEdit();
        m_editor->setEchoMode(QLineEdit::Password);
    
        auto buttonbox = new QDialogButtonBox(
                    QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
        connect(buttonbox, &QDialogButtonBox::accepted,
                this, &PasswordEntryDialog::accept);
        connect(buttonbox, &QDialogButtonBox::rejected,
                this, &PasswordEntryDialog::reject);
    
        auto mainlayout = new QFormLayout();
        mainlayout->setRowWrapPolicy(QFormLayout::WrapAllRows);
        mainlayout->addRow(prompt, m_editor);
        mainlayout->addWidget(buttonbox);
        setLayout(mainlayout);
    }
    

    I want the label to appear above the text box, taking up the same width as the box but wrapping if it is too long. So I set the rowWrapPolicy on the layout to WrapAllRows and wordWrap on the label to true.

    The result is that the label wraps at about half the width of the text box:
    password-dialog.png
    Is this a bug or do I need to do something else to the label or form?

    Previously I was using a VBoxLayout with the two widgets just added to the layout but on iOS, the dialog would stretch vertically to full screen, leaving a big gap between the label and the password entry field.

    Using Qt 5.12

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

      Hi,

      Which Linux distribution are you using ?
      Can you provide a minimal compilable example that shows the behaviour ?
      Can check with a more recent version of Qt like the latest LTS ?

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

      M 2 Replies Last reply
      0
      • SGaistS SGaist

        Hi,

        Which Linux distribution are you using ?
        Can you provide a minimal compilable example that shows the behaviour ?
        Can check with a more recent version of Qt like the latest LTS ?

        M Offline
        M Offline
        Martin Burchell
        wrote on last edited by
        #3

        @SGaist I'll answer the easy question first, which is Ubuntu 18.04.5 and get back to you on the others.

        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Which Linux distribution are you using ?
          Can you provide a minimal compilable example that shows the behaviour ?
          Can check with a more recent version of Qt like the latest LTS ?

          M Offline
          M Offline
          Martin Burchell
          wrote on last edited by
          #4

          @SGaist Minimal example at https://github.com/martinburchell/qt-dialog-label-bug

          1 Reply Last reply
          1
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Reproducible with your code, thx -> https://bugreports.qt.io/browse/QTBUG-89805

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            2

            • Login

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