QScrollArea не добавляет полосы прокруткиC++

Программы на C++. Форум разработчиков
Ответить Пред. темаСлед. тема
Anonymous
 QScrollArea не добавляет полосы прокрутки

Сообщение Anonymous »


I have to dynamically create push buttons depending on user inputs, therefore if the user gives a large input number, the widget containing the push buttons has to have the ability to scroll up and down.

For this reason, I am using QScrollArea. I generate the template in Qt designer and the UIC generates the code for me, after which I add in my part which should handle dynamic creation of push buttons. However, I can not seem to get the vertical scroll bars to appear. Here is the relevant part of the code.

verticalWidget = new QWidget(FWHMWorkflowDialog); verticalWidget->setObjectName(QString::fromUtf8("verticalWidget")); verticalWidget->setMinimumSize(QSize(150, 0)); verticalWidget->setMaximumSize(QSize(150, 16777215)); verticalLayout_5 = new QVBoxLayout(verticalWidget); verticalLayout_5->setObjectName(QString::fromUtf8("verticalLayout_5")); scrollArea = new QScrollArea(verticalWidget); scrollArea->setObjectName(QString::fromUtf8("scrollArea")); scrollArea->setMaximumSize(QSize(150, 16777215)); scrollArea->setWidgetResizable(true); scrollAreaWidgetContents = new QWidget(); scrollAreaWidgetContents->setObjectName(QString::fromUtf8("scrollAreaWidgetContents")); scrollAreaWidgetContents->setGeometry(QRect(0, 0, 130, 432)); numberOfSlices = numberSlices; for (int i = 0; i < numberOfSlices; i++) { QWidget *horizontalWidget = new QWidget(scrollAreaWidgetContents); horizontalWidget->setMaximumSize(150,40); horizontalWidget->setGeometry(QRect(0, i*40, 150, 40)); hWidgetList.push_back(horizontalWidget); QHBoxLayout *hLayout = new QHBoxLayout(horizontalWidget); hLayoutList.push_back(hLayout); hLayout->setSizeConstraint(QLayout::SetMinimumSize); hLayout->setContentsMargins(-1, 1, -1, 1); QPushButton *pushButton = new QPushButton(horizontalWidget); pushButtonList.push_back(pushButton); QString temp = QString("m_sliceButton").arg(i); pushButtonList->setObjectName(temp); pushButtonList->setGeometry(QRect(10, 20+i*40, 98, 27)); hLayout->addWidget(pushButton); QCheckBox *checkBox = new QCheckBox(horizontalWidget); checkBoxList.push_back(checkBox); temp = QString("m_checkBox").arg(i); checkBoxList->setObjectName(temp); checkBoxList->setEnabled(true); checkBoxList->setGeometry(QRect(110, 20+i*40, 21, 22)); hLayout->addWidget(checkBox); } scrollArea->setWidget(scrollAreaWidgetContents); //scrollArea->setWidgetResizable(true); verticalLayout_5->addWidget(scrollArea); The output window always looks like the following.


Изображение


In this example the input by the user is 25, however, you can see that the 21st button is cut off and 4 other buttons are not visible.

The size window problem occurring after scroll functionality started working.


Изображение



Источник: https://stackoverflow.com/questions/146 ... scrollbars
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • Css overflow-x: автоматически не добавляет полосы прокрутки при гибком отображении
    Anonymous » » в форуме CSS
    0 Ответы
    12 Просмотры
    Последнее сообщение Anonymous
  • Visual Studio 2022 C#, можно ли настроить richTextBox для вертикальной прокрутки текста (и вертикальные полосы прокрутки
    Anonymous » » в форуме C#
    0 Ответы
    124 Просмотры
    Последнее сообщение Anonymous
  • Как установить начальный размер QScrollArea?
    Anonymous » » в форуме C++
    0 Ответы
    22 Просмотры
    Последнее сообщение Anonymous
  • Автопрокрутка QScrollArea при изменении размера содержащегося виджета
    Гость » » в форуме C++
    0 Ответы
    25 Просмотры
    Последнее сообщение Гость
  • Автопрокрутка QScrollArea при изменении размера виджета
    Гость » » в форуме C++
    0 Ответы
    20 Просмотры
    Последнее сообщение Гость

Вернуться в «C++»