Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Solved Scrollbars don't show

    General and Desktop
    scrollbar
    5
    13
    6722
    Loading More Posts
    • 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.
    • G
      gabor53 last edited by

      Hi,
      I need a vertical scroll bar in mainwindow.ui. It doesn't come up automatically when a widget becomes hidden. What is the best way to display scroll bars?
      Thank you.

      Ratzz 1 Reply Last reply Reply Quote 0
      • Ratzz
        Ratzz @gabor53 last edited by

        @gabor53
        Here is one example.

        --Alles ist gut.

        1 Reply Last reply Reply Quote 0
        • G
          gabor53 last edited by

          Can I use QDialog as widget for scroll bar?

          1 Reply Last reply Reply Quote 0
          • raven-worx
            raven-worx Moderators last edited by raven-worx

            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 Reply Quote 0
            • G
              gabor53 last edited by

              I added QScrollArea. Only a rectangle appeared without arrows. What did I do incorrectly?
              (I added in Designer).
              Thank you.

              raven-worx 1 Reply Last reply Reply Quote 0
              • raven-worx
                raven-worx Moderators @gabor53 last edited by

                @gabor53
                probably you either haven't set a child widget, so no scrollbars are necessary.
                Or you need to adapt the scrollarea's scrollbar-policy.

                --- 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 Reply Quote 1
                • G
                  gabor53 last edited by

                  I used the following code to add the scroll bar to the window:

                  
                      QScrollArea *scroll = new QScrollArea(this);
                      scroll->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOn);
                      scroll->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOn);
                  
                      QWidget *viewport  = new QWidget(this);
                      scroll->setWidget (viewport);
                      scroll->setWidgetResizable (true);
                  
                  	QHBoxLayout *l = new QHBoxLayout(viewport);
                      viewport->setLayout (l);
                  
                      //Add widgets
                      l->addWidget (ui->label);
                      l->addWidget (ui->ID_Display);
                  
                  
                  
                      QHBoxLayout *dialog_layout = new QHBoxLayout(this);
                      this->setLayout(dialog_layout);
                      this->layout ()->addWidget (scroll);
                      this->show ();
                  

                  It does add the scroll bar, but when I add the widgets They appear randomly in the window opened. How can I keep the original design?

                  Thank you.

                  1 Reply Last reply Reply Quote 0
                  • N
                    N.Sumi last edited by N.Sumi

                    Hi @gabor53

                    you get scroll bars only when you set the child widgets in it,. No child widget means, you don't need/ get any scroll bars.
                    By default, the scroll bars are displayed only when the viewport is smaller than the child widget. You can force the scroll bars to always be shown by setting scroll bar policies.

                    QScrollArea scrollArea;
                    scrollArea.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
                    scrollArea.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);

                    I made a small sample with Designer , you can check this.

                    https://www.dropbox.com/sh/sw0hxogg3x9xq3e/AADwVRL6NSZtLK_8q2iOgLPIa?dl=0

                    Q 1 Reply Last reply Reply Quote 2
                    • G
                      gabor53 last edited by

                      I created a scroll area in Designer and moved all the widget into the scroll area. I see the widgets, and there are scroll bars on the side but they are inactive. How can I set the view area in a way, that when some of the widgets are off the screen the scrollbars show and work?
                      Thank you.

                      1 Reply Last reply Reply Quote 0
                      • G
                        gabor53 last edited by

                        I created the following in Designer. It is clear that several lineEdits can't be seen, but there is still no sidebar. Any Idea why? Thank you.

                        [Files]([https://www.dropbox.com/sh/wkyuq64trxk2lrq/AAAmWPeosw4qSUSkJj9AQG5fa?dl=0](link url))

                        1 Reply Last reply Reply Quote 0
                        • N
                          N.Sumi last edited by

                          Hi @gabor53

                          Seems the problem is with QDialog & you have used layout wrongly.

                          Refer to this link, if you are going QDialog. You have solution.

                          1 Reply Last reply Reply Quote 0
                          • G
                            gabor53 last edited by

                            Thank you. It worked.

                            1 Reply Last reply Reply Quote 0
                            • Q
                              Qt_Python Learner @N.Sumi last edited by Qt_Python Learner

                              @N-Sumi @gabor53 Hey, Sorry I get that this is quite old post. But asking incase if you have a solution. I understood how to add this in code and get it. But is there a way to set this property in QtDesigner? So that every time I modify my design, I need not type explicitly in the generated code. I cannot find this property. Could you please let me know if we can do this in Qt designer

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post