Important: Please read the Qt Code of Conduct -

Make Widget visible in QScrollArea (by Layout)

  • Hello,

    I ve implemented a FlowGridLayout (similar to and added some cursor functionality (pressing left-key will focus the left element, pressing down-key will focus the bottom element) to the layout, since it's the only object which knows the row-/column-count.

    How can I make an item visible, when it's hidden by a QScrollArea? Since I only have a pointer to the item, I have no access to the scroll area. With setting "QScrollArea::setWidget()", the widget is only assigned to the viewport (widget) - but not to the scroll area.

    I found a very very very ugly workaround:
    if( pNewWidget != NULL )
    pNewWidget->previousInFocusChain()->setEnabled( false );
    // Now the 'pNewWidget' is visible
    pNewWidget->previousInFocusChain()->setEnabled( true );

    But there must be a better solution...!

    Best Regards,

Log in to reply