Qt Forum

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

    Update: Forum Guidelines & Code of Conduct

    Examples of setting up a QScrollArea

    General and Desktop
    2
    2
    1165
    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.
    • K
      kloveridge last edited by

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • First post
          Last post