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. [SOLVED]QtabWidget, how to make it scrollable
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]QtabWidget, how to make it scrollable

Scheduled Pinned Locked Moved General and Desktop
17 Posts 4 Posters 19.6k 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.
  • S Offline
    S Offline
    sharon_obl82
    wrote on last edited by
    #1

    Hi,
    I'm sorry if I created a duplicate thread but I couldn't find anything on this thread in search so I'm posting this question.
    I created a Tab widget using QT Designer and I want to make the contents in the tab area to be scrollable so my form will not be too long. Appreciate it if someone can help to advise on it.
    Thank you

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      Put a QScrollArea on the tab, and the widgets you want inside the scroll area

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        You don't make the tab widget scrollable, but instead you add a widget on the tab that provides the scrolling. Simply place a QScrollArea widget as your only widget on the tab, and place your form elements on that widget.

        Better yet: design your forms in such a way that no scrolling is needed :)

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sharon_obl82
          wrote on last edited by
          #4

          ermm, i tried just that but it still doesn't show?

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

            Without showing us what you did, it is hard for us to see what you did wrong...

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sharon_obl82
              wrote on last edited by
              #6

              sorry, but here's a snapshot i took.

              http://i57.tinypic.com/14ncz2p.png

              as you can see on the right, there are some widgets under the Scrollarea. I just kinda position the widgets under it and try to run it.
              Am i missing something else?

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

                Try putting everyting in proper layouts.

                1 Reply Last reply
                0
                • Z Offline
                  Z Offline
                  zeljko
                  wrote on last edited by
                  #8

                  Looks like scrollbars policy is Qt::ScrollBarAlwaysOff (if container of your widgets is is QScrollArea).It should be Qt::ScrollBarAsNeeded (default) or Qt::ScrollBarAlwaysOn , so then you'll get desired result.

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    sharon_obl82
                    wrote on last edited by
                    #9

                    yes, the scrollbar policy is set to Qt::ScrollBarAsNeeded. I changed it to Qt::ScrollBarAlwaysOn but it's not scrollable :(

                    1 Reply Last reply
                    0
                    • Z Offline
                      Z Offline
                      zeljko
                      wrote on last edited by
                      #10

                      strange, looks like controls parent isn't QScrollArea.
                      Have you tried same thing on QMainWindow (add QScrollArea + child controls) ?

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        sharon_obl82
                        wrote on last edited by
                        #11

                        Hi,
                        I tested with just adding QScrollArea and child controls on the QMainWindow but the scrollbar doesn't appear too when it's being run. :O

                        1 Reply Last reply
                        0
                        • Z Offline
                          Z Offline
                          zeljko
                          wrote on last edited by
                          #12

                          Then I really don't know what's up.

                          1 Reply Last reply
                          0
                          • C Offline
                            C Offline
                            ChrisW67
                            wrote on last edited by
                            #13

                            Andre has a good suggestion.

                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              sharon_obl82
                              wrote on last edited by
                              #14

                              Thanks guys, it was because of the layout problem. Btw, everytime i click "Layout in a Form layout" the scroll area automatically resizes to a small box on the top left corner. Is there a way to prevent this?

                              1 Reply Last reply
                              0
                              • C Offline
                                C Offline
                                ChrisW67
                                wrote on last edited by
                                #15

                                Apply a layout at every level, including on the widget that contains the QScrollArea... Everywhere you see the Layout-with-a-red-crossed-circle icon in the Object Inspector should be looked at.

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

                                  If you use layouts, you have to use layouts all the way:

                                  • Every widget (except the top level one) has to be in a layout
                                  • Every widget that contains other widgets has to have a layout.

                                  Recursively.

                                  1 Reply Last reply
                                  0
                                  • S Offline
                                    S Offline
                                    sharon_obl82
                                    wrote on last edited by
                                    #17

                                    Ok I understand. Thank Andre!

                                    1 Reply Last reply
                                    0

                                    • Login

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