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. How to set scroll bar to a stacked widget?
Forum Updated to NodeBB v4.3 + New Features

How to set scroll bar to a stacked widget?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 833 Views 2 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
    Adit
    wrote on last edited by
    #1

    Hi All,I m new to qt and have so far used the designer mode to brings items in place.I have a stacked widget with several items.

    StackedWidget
    |_Item1
    |_Item2
    |_Item3
    I want to add a scroll bar(both horizontal and vertical ) to my stackedwidget.

    Things I have done:

    1. In the designer,I have the below but its showing the scrollbars ,but not getting scrolled.

         ScrollArea
          |_QWidget                                          
           |_StackedWidget
      

    2.I had only StackedWidget in my GUI and added the scrollarea and QWidget programmatically.

         QWidget * mainWidget = new QWidget(ui->stackedWidget);
         QVBoxLayout * vLayout = new QVBoxLayout(mainWidget);
         QScrollArea * scrollArea = new QScrollArea(mainWidget);
    
         scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
         scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
         scrollArea->setWidgetResizable(true);
    
         vLayout->addWidget(scrollArea);
    

    But now,the scrollbar is not getting shown.Any help woould be really helpful.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Something is not clear, do you want your stacked widget to be in a QScrollArea programmatically ? Or have the scroll area to be inside the QStackedWidget ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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