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 use QHeaderView in QScrollArea?
Forum Updated to NodeBB v4.3 + New Features

How to use QHeaderView in QScrollArea?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qheaderview
2 Posts 2 Posters 1.4k 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
    AlaaM
    wrote on 18 Feb 2016, 11:50 last edited by
    #1

    I have a QScrollArea, which includes a QGroupBox:

    scrollArea = new QScrollArea(&widget);
    groupBoxLayout = new QVBoxLayout();
    groupBox = new QGroupBox();
    
    //add buttons to the layout
    groupBoxLayout->addWidget(buttons[i]);
    
    groupBox->setLayout(groupBoxLayout);
    scrollArea->setWidget(groupBox);
    

    I'm trying to add a fixed header to the layout. A header that will always be visible no matter if I scroll down. So I did this:

    header = new QHeaderView(Qt::Horizontal);
    header->setSectionsMovable(false);
    groupBoxLayout->addWidget(header);
    

    before adding the buttons.

    • The header appears on top of the buttons in the layout but it's empty (of course - I didn't put anything in it).
    • When I scroll down, the header disappears (gets scrolled).
      How do I get it to be fixed? Maybe it needs to not be a part of the scrollarea?

    Thanks

    K 1 Reply Last reply 18 Feb 2016, 11:53
    0
    • A AlaaM
      18 Feb 2016, 11:50

      I have a QScrollArea, which includes a QGroupBox:

      scrollArea = new QScrollArea(&widget);
      groupBoxLayout = new QVBoxLayout();
      groupBox = new QGroupBox();
      
      //add buttons to the layout
      groupBoxLayout->addWidget(buttons[i]);
      
      groupBox->setLayout(groupBoxLayout);
      scrollArea->setWidget(groupBox);
      

      I'm trying to add a fixed header to the layout. A header that will always be visible no matter if I scroll down. So I did this:

      header = new QHeaderView(Qt::Horizontal);
      header->setSectionsMovable(false);
      groupBoxLayout->addWidget(header);
      

      before adding the buttons.

      • The header appears on top of the buttons in the layout but it's empty (of course - I didn't put anything in it).
      • When I scroll down, the header disappears (gets scrolled).
        How do I get it to be fixed? Maybe it needs to not be a part of the scrollarea?

      Thanks

      K Offline
      K Offline
      kshegunov
      Moderators
      wrote on 18 Feb 2016, 11:53 last edited by
      #2

      @AlaaM
      Hello,

      How do I get it to be fixed? Maybe it needs to not be a part of the scrollarea?

      This would be my choice, yes. I'd put the header and the scroll area in a vertical layout (setting the stretches to 0 for the header and 1 for the scroll area) and take it from there.

      Kind regards.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      0

      2/2

      18 Feb 2016, 11:53

      • Login

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