I use above function like this,
m_scrollArea->ensureWidgetVisible(QLineEdit,100,100);
No effect in GUI behavioour....
How Do I use, this function QScrollArea::ensureWidgetVisible. Do I need check everytime?
I use above function like this,
m_scrollArea->ensureWidgetVisible(QLineEdit,100,100);
No effect in GUI behavioour....
How Do I use, this function QScrollArea::ensureWidgetVisible. Do I need check everytime?
Do you need to check what? When you want a particular widget to be visible, just call this method with appropriate parametres.
The hierarchy is as follows.
QLineEdit is added to QBoxVLayout
QBoxVLayout is added to QWidget
QWidget is added QScrollArea.
So QLineEdit is child of QScrollArea.
When I use Tab, then it should call ensureWidgetVisible(). How can I implement this?
Thanks and Regards
C V Rao
ensureWidgetVisible will not work because the line edit is not a direct child.
Use ensureVisible instead and pass the pos of the line edit. The position of the line edit is available from QWidget::geometry().
The item that must be visible is the one that has the focus, so you probably have to iterate through all the children in the widget from the scroll area to find the lie edit that has the focus.
Regards
I don't know what's the actual problem here because QScrollArea already does ensure the child widget becomes visible:
Qt Code:
/*! \reimp */ { ensureWidgetVisible(fw); return true; } return false; }To copy to clipboard, switch view to plain text mode
Subclass QScrollArea and reimplement focusNextPrevChild() to fine tune scroll bar values if you're not happy with the default behaviour.
J-P Nurmi
I take back what I said
The scroll area knows if it is an ancestor of the line edit.
So the problem could be that you do not parent the widgets correctly.
Could you debug ensureWidgetVisible?
Or, at least see what scrollarea->widget()->isAncestorOf( lineEdit ) returns.
Regards
scrollarea->widget()->isAncestorOf( lineEdit ) is returning true.
I tries to subclass ScrollArea, but I got many compilation error as we are inherting this class from our own classes.
Thanks
cvrao
Bookmarks