Resizing widget because of a scroll area



  • I have a two column QTableWidget element where I add rows of data as needed. When the number of rows exceeds the length of the view area, the vertical scroll bar conveniently appears automatically (I assume through the AsNeeded property of the QScrollArea). However, the scroll bar hides part of the contents of the QTableWidget. I'd like to increase the size of the element when the scroll area appears, ideally through signals & slots, such that the scroll bar isn't hiding the data when it appears.

    I'm using QT Creator. I've looked at the documentation for the base classes and the ui_.h file to see how the QTableWidget is initialized but I'm not finding any signals for the scroll bar enabled. QScrollArea has a setResizeWidget() function but it doesn't seem that QWidgets use QScrollArea's but rather directly QScrollBar's.

    Does anyone have any suggestions?


  • Lifetime Qt Champion

    Hi,

    On possibility could be to use an event filter on the scroll bar and check for the QEvent::Show event.

    Hope it helps



  • That worked!! Thanks for the suggestion!!!


Log in to reply
 

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