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. Examples of setting up a QScrollArea

Examples of setting up a QScrollArea

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.3k Views
  • 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.
  • K Offline
    K Offline
    kloveridge
    wrote on last edited by
    #1

    Ugh. Scrollbars.

    I have a need where I have a splitter with two panels. On the left panel, I need to insert a QScrollArea. Inside the QScrollArea, I have custom QWidget that draws a custom hierarchy tree.

    So far, I have things sorta working with this setup code:

    @ m_hierWindow = new HierWidget(this);
    m_hierWindow->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

    // SETUP MAIN WINDOW
    m_scroller = new QScrollArea(this);
    m_scroller->setBackgroundRole(QPalette::Dark);
    ui->TreeView->addWidget(m_scroller);
    ui->ModelView->addWidget(m_model);

    m_scroller->setWidget(m_hierWindow);
    @

    Can someone point me to a good tutorial of how to setup the QScrollArea inside a splitterwindow? I see this done all the time in Qt Creator. It can't be that difficult.

    Thanks in Advance

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

      Hi,

      The code you posted is a bit confusing.

      @
      ui->TreeView->addWidget(m_scroller); <- TreeView is a layout ?
      ui->ModelView->addWidget(m_model); <- ModelView is a layout ? m_model a widget ?
      @

      In short for using a QScrollArea in a QSplitter:

      @
      QSplitter *splitter = new QSlitter;
      QScrollArea *scrollArea = new QScrollArea;
      splitter->addWidget(scrollArea);

      // Modify scrollArea as you see fit
      @

      Hope it helps

      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