Qt Forum

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

    Unsolved How to use QHeaderView in QScrollArea?

    General and Desktop
    qheaderview
    2
    2
    1109
    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.
    • A
      AlaaM last edited by

      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

      kshegunov 1 Reply Last reply Reply Quote 0
      • kshegunov
        kshegunov Moderators @AlaaM last edited by

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