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. Getting QScrollArea dimensions
Qt 6.11 is out! See what's new in the release blog

Getting QScrollArea dimensions

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.9k Views 1 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.
  • W Offline
    W Offline
    willypuzzle
    wrote on last edited by
    #1

    I fail to get QScrollArea dimensions, I tried geometry(), width(), height() and others but I always get understimated dimensions of the real borders.
    Ho can I do?

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

      @willypuzzle said:
      you mean like
      QScrollArea f;
      f.viewport()->contentsRect();
      ?

      1 Reply Last reply
      0
      • W Offline
        W Offline
        willypuzzle
        wrote on last edited by
        #3

        I have this code:

        • centralWidgetContainer = new QScrollArea(this);
          CentralWidget* centralWidget = new CentralWidget(centralWidgetContainer);
          centralWidgetContainer->setWidget(centralWidget);
          centralWidgetContainer->setMinimumHeight(this->height() - centralWidgetContainerSizeGap);
          centralWidgetContainer->setMidLineWidth(this->width());

        When I try (from inside CentralWidget, that extends QFrame) something like:

        • QRect rect = ((QScrollArea*)this->parent())->viewport()->contentsRect();

        I got a rect with very understimate height and width values (respect this->height() and this->width() of the code above).

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          well I think QMainwindow centralwidget have a default layout so
          maybe its the one altering the rect.

          Do you try to reserve some space or what is the purpose?

          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