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

On MacOs QScrollArea::setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn) does not always display the vertical scroll bar

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P3: Somewhat important
    • None
    • 6.5.2
    • Widgets: Styles
    • None
    • MacOs
    • macOS

    Description

      On MacOs with Qt 6.5.2 using QScrollArea: regardless of whether setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn) is called, the vertical scrollbar is only shown when needed and not all the time. 

      Expected: the vertical scroll bar should always be shown.

       

      #include <QApplication>
      #include <QDialog>
      #include <QLayout>
      #include <QScrollArea>
      #include <QSize>
      #include <QWidget>
      #include <QLabel>
      #include <QPushButton>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          QDialog dialog;
          auto dialogLayout = new QVBoxLayout(&dialog);
          QWidget* mainWidget = new QWidget;
          QVBoxLayout* mainLayout = new QVBoxLayout(mainWidget);
          dialogLayout->addWidget(mainWidget);
          QWidget* topWidget = new QWidget;
          QScrollArea* topScrollArea = new QScrollArea;
          topScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
          topScrollArea->setWidget(topWidget);
          topScrollArea->setWidgetResizable(true);
          mainLayout->addWidget(topScrollArea);
          topScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
          QVBoxLayout *topLayout = new QVBoxLayout();
          topWidget->setLayout(topLayout);
          for (int i = 0; i < 10; i++){
              QPushButton *tempButton = new QPushButton(QString("%1").arg(i));
              tempButton->setMinimumHeight(50);
              topLayout->addWidget(tempButton);
          }
          dialog.show();
          return a.exec();
      }
      

       

      Attachments

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

        Activity

          People

            tpochep Timur Pocheptsov
            myk Michael Arnold
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes