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

Documentation: wrong default value for Layout Direction

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 5.15.0 RC2
    • Documentation
    • None
    • All

      The documentation for LayoutDirection says this:

      https://doc.qt.io/qt-5/qwidget.html#layoutDirection-prop

      says this:

      By default, this property is set to Qt::LeftToRight.

      As such, in the following program:

      #include <QApplication>
      
      #include <QHBoxLayout>
      #include <QPushButton>
      #include <QMainWindow>
      
      int main(int argc, char *argv[])
      {
       QApplication a(argc, argv);
      
      QMainWindow *window = new QMainWindow;
       window->setLayoutDirection( Qt::LeftToRight ); // This line shouldn't make a difference
       QWidget *widget = new QWidget;
       QPushButton *button1 = new QPushButton("One");
       QPushButton *button2 = new QPushButton("Two");
       QPushButton *button3 = new QPushButton("Three");
       QPushButton *button4 = new QPushButton("Four");
       QPushButton *button5 = new QPushButton("Five");
      
      QHBoxLayout *layout = new QHBoxLayout;
       layout->addWidget(button1);
       layout->addWidget(button2);
       layout->addWidget(button3);
       layout->addWidget(button4);
       layout->addWidget(button5);
      
      widget->setLayout(layout);
       window->setCentralWidget(widget);
       window->show();
      
      return a.exec();
      }
      

      The setLayoutDirection line should not make any difference. The truth is, however, that it does. If I call it, the program does not automatically mirror.

      I'm not sure what the correct fix is, but the documentation as it currently stands does not reflect what's actually going on.

        For Gerrit Dashboard: QTBUG-85839
        # Subject Branch Project Status CR V

            docteam Qt Documentation Team
            shachar Shachar Shemesh
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes