How to get the real size of a scrollable Widget



  • Hi there!
    I would like to put 2 QTableWidgets, which are much bigger than the screen is, inside a QScrollArea. I want the QTableWidgets to be placed with their maximum size inside the QScrollArea so that I can scroll them only with the scrollbars of the QScollArea.

    So I did the following:

    @ QFrame* frame = new QFrame(this);
    QVBoxLayout* layout = new QVBoxLayout(frame);
    QScrollArea scroll = new QScrollArea(this);
    MyTabeWidget
    jt1 = new MyTabeWidget(this);
    MyTabeWidget* jt2 = new MyTabeWidget(this);
    frame->setLayout(layout);
    layout->addWidget(jt1);
    layout->addWidget(jt2);
    scroll->setWidget(frame);
    this->setCentralWidget(scroll);@

    MyTabeWidget is derived from QTableWidget.
    But if I do so I have a large QMainWindow which holds my QScrollArea, which has no scrollbars, and there are 2 tiny MyTabeWidgets in it having both scrollbars.

    How can I insert the MyTabeWidgets with their maximum sizo, so that they dont have any scrollbars by their own.

    Thank you!


  • Moderators

    Hi,

    Put both QTableWidgets in a vertical layout in a QScrollArea.

    Then set them :
    fixed size
    AdjustToContents
    ScrollBarAlwaysOff

    that should do the trick.

    hope it helps


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.