Hi
In my application, multiple of QLineEdit widgets are added to Vertical List(QVBoxLayout). I also enabled Vertical Scroll Bar.
Please see attached jpeg file image. I would like to know how to solve this kind of problems.
Thanks
C V rao
Hi
In my application, multiple of QLineEdit widgets are added to Vertical List(QVBoxLayout). I also enabled Vertical Scroll Bar.
Please see attached jpeg file image. I would like to know how to solve this kind of problems.
Thanks
C V rao
Do you use a scroll area or something like that? Could you provide more details?
Yes I used ScrollArea and set the properties to scroll area
m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysO ff);
m_scrollArea->setWidgetResizable(true);
m_scrollArea->setLineWidth(0);
m_scrollArea->setFixedHeight(191);
m_scrollArea->setWidget(emailVListArea);
m_scrollArea->setFixedSize(780,191);
no_pixestoJump = TOP_SPACING + fromLabel->size().height() + (BUTTON_HEIGHT - EMAILAPP_BUTTON_HEIGHT) + fromEditBox->size().height()
m_scrollArea->verticalScrollBar()->setSingleStep(no_pixestoJump);
If I use mouse, scroll bar moving correctly means jumping no_pixestoJump up or down.
When I use TAB same thing is not happen, it is moving incorrectly...
Why should it scroll if you use tab?
My question is Children widgets of ScrollArea is not shown properly when I use TAB.
Did you implement that somehow? What about the tab order, does it work?
Tab order is working fine.
If I press Vertical Scroll Bar Up/Down buttons, Scroll Area Filelds are moving X pixes Up/Down , X is an integer argument passed to verticalScrollBar()->setSingleStep(X).
But When I use Tab ,the child widgets of scroll area are not shown properly.
Exmple: I have 7 QLineEdit widgets in my scroll area. let say Scroll Area can hold only 5 QLineEdit widgets at any time.
When I use Tab focus come to 1 st QLineEdit
Again Tab, focus come to 2nd QLineEdit
Again Tab, focus come to 3rd QLineEdit
Again Tab, focus come to 4th QLineEdit
Again Tab, focus come to 5th QLineEdit
Till this point Childwidgets are not moved up. This is correct as ScrollAre hold 5 LineEdits Widgets.
Again Tab, focus come to 6th QLineEdit.
Expected Behaviour: First QLineEdit is showing half.
Wanted Behaviour : First QlineEdit should go up fully. 2,3,4,5,6 QlineEdit widgets should show.
How do I implement the above wanted behaviour?
Thanks
C V Rao
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