Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-1994

Wordwrap label on the Mac cause the label to have a large height

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P3: Somewhat important
    • Some future release
    • 4.4.0
    • Widgets: Layout
    • None
    • macOS

    Description

      Setting wordwrap to a label on Mac causes it to get a big space on the top and on the bottom.
      If the wordwrap is turned off it looks normal.

      This does not happen on Windows.

      Reproducible with the following example:

      #include <QtGui>

      class dialog : public QDialog
      {
      Q_OBJECT
      public:
      dialog(QWidget* parent = 0)
      : QDialog(parent)

      { QGridLayout* gridLayout = new QGridLayout(this); gridLayout->setObjectName(QString::fromUtf8("gridLayout")); // gridLayout->setHorizontalSpacing(6); // gridLayout->setVerticalSpacing(6); // gridLayout->setContentsMargins(0, 0, 0, 0); QLabel *label_3 = new QLabel(); label_3->setObjectName(QString::fromUtf8("label_3")); QSizePolicy sizePolicy2(static_cast<QSizePolicy::Policy>(1), static_cast<QSizePolicy::Policy>(0)); // sizePolicy2.setHorizontalStretch(0); // sizePolicy2.setVerticalStretch(0); // sizePolicy2.setHeightForWidth(label_3->sizePolicy().hasHeightForWidth()); label_3->setSizePolicy(sizePolicy2); label_3->setFrameShape(QFrame::Box); label_3->setFrameShadow(QFrame::Sunken); label_3->setWordWrap(true); // label_3->setMargin(4); // label_3->setIndent(15); label_3->setText(QApplication::translate("textEditWidget", "You can use virtually any rich text markup to modify the text. However, not all special characters are available on all platforms.", 0, QApplication::UnicodeUTF8)); QPushButton* pb2 = new QPushButton("ok", this); connect(pb2, SIGNAL(clicked()), this, SLOT(accept())); gridLayout->addWidget(label_3, 0, 0, 1, 2); gridLayout->addWidget(pb2, 1, 1, 1, 1); }

      private:
      QLabel *sourceLabel;
      };

      class widget : public QMainWindow
      {
      Q_OBJECT
      public:
      widget(QWidget* parent = 0)
      : QMainWindow(parent)

      { QPushButton* pb = new QPushButton("show dialog", this); connect(pb, SIGNAL(clicked()), this, SLOT(showdialog())); }

      private slots:
      void showdialog()

      { dialog dlg; dlg.exec(); }

      };

      #include "main.moc"

      int main(int argc, char **argv)
      {
      QApplication a(argc, argv);
      widget w;
      w.show();
      return a.exec();
      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            admin Administrator
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes