Make Widget visible in QScrollArea (by Layout)



  • Hello,

    I ve implemented a FlowGridLayout (similar to http://doc.trolltech.com/4.7/layouts-flowlayout.html) 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()->setFocus();
    pNewWidget->previousInFocusChain()->setEnabled( false );
    // Now the 'pNewWidget' is visible
    pNewWidget->previousInFocusChain()->setEnabled( true );
    pNewWidget->setFocus();
    }
    @

    But there must be a better solution...!

    Best Regards,
    Charly


Log in to reply
 

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