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. scrollbar in QGroupBox
Forum Updated to NodeBB v4.3 + New Features

scrollbar in QGroupBox

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 2 Posters 8.1k 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.
  • A Offline
    A Offline
    Apeksha
    wrote on last edited by
    #1

    Hi,

    I want to add scrollbar in QGroupbox, how to do it, Can you please guide me?
    Scrollbar should appear when groupbox is minimized.

    Please suggest me, Thanks in advance.

    raven-worxR 1 Reply Last reply
    0
    • A Apeksha

      Hi,

      I want to add scrollbar in QGroupbox, how to do it, Can you please guide me?
      Scrollbar should appear when groupbox is minimized.

      Please suggest me, Thanks in advance.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by SGaist
      #2

      @Apeksha
      simply use a QScrollArea

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      2
      • A Offline
        A Offline
        Apeksha
        wrote on last edited by
        #3

        Hi raven-worx,

        Yes I am using Scrollarea, but i need scrollbar when my gui has minimized. suppose my widget is of size 500x500, when it is minized, suppose to 300x200 then only scrollbar should appear. I hope you got my point.

        raven-worxR 1 Reply Last reply
        0
        • A Apeksha

          Hi raven-worx,

          Yes I am using Scrollarea, but i need scrollbar when my gui has minimized. suppose my widget is of size 500x500, when it is minized, suppose to 300x200 then only scrollbar should appear. I hope you got my point.

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @Apeksha
          isn't that the default behavior of QScrollArea anyways?!

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Apeksha
            wrote on last edited by
            #5

            Hi raven-worx,

            Actually my requirement is, I have to add scrollbar to groupbox and it should visible when it is minimized.

            Please help me.
            Thanks in advance.

            raven-worxR 1 Reply Last reply
            0
            • A Apeksha

              Hi raven-worx,

              Actually my requirement is, I have to add scrollbar to groupbox and it should visible when it is minimized.

              Please help me.
              Thanks in advance.

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              @Apeksha said in scrollbar in QGroupBox:

              Actually my requirement is, I have to add scrollbar to groupbox and it should visible when it is minimized.

              yes i got that. And again, this is what QScrollArea already does by default.
              So maybe you can post a screenshot of your issue.

              Maybe you want to use scrollArea->setWidgetResizeable( true ) but still set a minimum size of the content-widget inside the scroll area. When the scroll area gets smaller than the minimum size the scrollbars will be shown. If it is bigger then the specified minimum-size the widget will be resized and use the extra space.

              Is that what you want?

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              1
              • A Offline
                A Offline
                Apeksha
                wrote on last edited by Apeksha
                #7

                Hi raven-worx,

                QHBoxLayout *ConfigurationLayout = new QHBoxLayout;
                QScrollArea* scrollArea = new QScrollArea();
                scrollArea->setStyleSheet("QScrollArea {background-color:gray;}");
                ConfigurationLayout->addWidget(ui->configurationBox);////ui->configurationbox is QGroupBox.
                mainBoxLayout->addLayout(ConfigurationLayout);
                

                This is correctway or anything wrong I am doing.

                raven-worxR 1 Reply Last reply
                0
                • A Apeksha

                  Hi raven-worx,

                  QHBoxLayout *ConfigurationLayout = new QHBoxLayout;
                  QScrollArea* scrollArea = new QScrollArea();
                  scrollArea->setStyleSheet("QScrollArea {background-color:gray;}");
                  ConfigurationLayout->addWidget(ui->configurationBox);////ui->configurationbox is QGroupBox.
                  mainBoxLayout->addLayout(ConfigurationLayout);
                  

                  This is correctway or anything wrong I am doing.

                  raven-worxR Offline
                  raven-worxR Offline
                  raven-worx
                  Moderators
                  wrote on last edited by
                  #8

                  @Apeksha
                  you dont add any widget to the scroll-area, i dont see any group-box widget and i don't see any setWidgetResizable() call.
                  Hard to say if you are doing all right, when you just post half of the code.

                  --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                  If you have a question please use the forum so others can benefit from the solution in the future

                  1 Reply Last reply
                  1
                  • A Offline
                    A Offline
                    Apeksha
                    wrote on last edited by
                    #9

                    QHBoxLayout *ConfigurationLayout = new QHBoxLayout;
                    QScrollArea *scrollArea = new QScrollArea;
                    scrollArea->setStyleSheet("QScrollArea {background-color:gray;}");
                    // ui->scrollArea->widgetResizable(true);
                    // scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
                    // scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
                    scrollArea->setWidget(ui->configurationBox);
                    ConfigurationLayout->addWidget(ui->configurationBox);
                    scrollArea->setWidgetResizable(true);
                    // ConfigurationLayout->addWidget(ui->scrollArea);
                    mainBoxLayout->addLayout(ConfigurationLayout);

                    raven-worxR 1 Reply Last reply
                    0
                    • A Apeksha

                      QHBoxLayout *ConfigurationLayout = new QHBoxLayout;
                      QScrollArea *scrollArea = new QScrollArea;
                      scrollArea->setStyleSheet("QScrollArea {background-color:gray;}");
                      // ui->scrollArea->widgetResizable(true);
                      // scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
                      // scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
                      scrollArea->setWidget(ui->configurationBox);
                      ConfigurationLayout->addWidget(ui->configurationBox);
                      scrollArea->setWidgetResizable(true);
                      // ConfigurationLayout->addWidget(ui->scrollArea);
                      mainBoxLayout->addLayout(ConfigurationLayout);

                      raven-worxR Offline
                      raven-worxR Offline
                      raven-worx
                      Moderators
                      wrote on last edited by
                      #10

                      @Apeksha
                      so still no setMinimumSize() call...
                      Beside that, are there any questions left from your side?!

                      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                      If you have a question please use the forum so others can benefit from the solution in the future

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        Apeksha
                        wrote on last edited by
                        #11

                        Hi

                        I am little bit confusing, Can you please post lines of code.

                        raven-worxR 1 Reply Last reply
                        0
                        • A Apeksha

                          Hi

                          I am little bit confusing, Can you please post lines of code.

                          raven-worxR Offline
                          raven-worxR Offline
                          raven-worx
                          Moderators
                          wrote on last edited by
                          #12

                          @Apeksha

                          QWidget* contentWidget = ...
                               contentWidget->setMinimumSize( 500,500 );
                          
                          QScrollArea *scrollArea = new QScrollArea;
                              scrollArea->setStyleSheet("QScrollArea {background-color:gray;}");
                              scrollArea->setWidget( contentWidget );
                              scrollArea->setWidgetResizable(true);
                          
                          QVBoxLayout* groupBoxLayout = new QVBoxLayout;
                                groupBoxLayout->addWidget( scrollArea );
                          QGroupBox* groupBox = ...
                                groupBox->setLayout( groupBoxLayout );
                          

                          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                          If you have a question please use the forum so others can benefit from the solution in the future

                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            Apeksha
                            wrote on last edited by
                            #13

                            QHBoxLayout *ConfigurationLayout = new QHBoxLayout;
                            QScrollArea *scrollArea = new QScrollArea;
                            scrollArea->setStyleSheet("QScrollArea {background-color:rgb(215,214,213);}");
                            scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
                            scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
                            scrollArea->setWidget(ui->configurationBox);
                            //ConfigurationLayout->addWidget(ui->configurationBox);
                            scrollArea->setWidgetResizable(true);
                            scrollArea->setMinimumSize(811,50);
                            ConfigurationLayout->addWidget(scrollArea);
                            mainBoxLayout->addLayout(ConfigurationLayout);

                            raven-worxR 1 Reply Last reply
                            1
                            • A Apeksha

                              QHBoxLayout *ConfigurationLayout = new QHBoxLayout;
                              QScrollArea *scrollArea = new QScrollArea;
                              scrollArea->setStyleSheet("QScrollArea {background-color:rgb(215,214,213);}");
                              scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
                              scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
                              scrollArea->setWidget(ui->configurationBox);
                              //ConfigurationLayout->addWidget(ui->configurationBox);
                              scrollArea->setWidgetResizable(true);
                              scrollArea->setMinimumSize(811,50);
                              ConfigurationLayout->addWidget(scrollArea);
                              mainBoxLayout->addLayout(ConfigurationLayout);

                              raven-worxR Offline
                              raven-worxR Offline
                              raven-worx
                              Moderators
                              wrote on last edited by
                              #14

                              @Apeksha
                              yes...and?
                              Do you have a question?? Does it work for you or not?!

                              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                              If you have a question please use the forum so others can benefit from the solution in the future

                              1 Reply Last reply
                              1
                              • A Offline
                                A Offline
                                Apeksha
                                wrote on last edited by
                                #15

                                No, when I minimized, scrollbar is not coming.

                                1 Reply Last reply
                                0
                                • A Offline
                                  A Offline
                                  Apeksha
                                  wrote on last edited by
                                  #16

                                  Hi raven-worx,

                                  Thank you for help, it's working fine.

                                  1 Reply Last reply
                                  1

                                  • Login

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