Results 1 to 16 of 16

Thread: ScrollBar is not moving properly when I use TAB

  1. #1
    Join Date
    May 2007
    Posts
    16
    Thanked 1 Time in 1 Post

    Default ScrollBar is not moving properly when I use TAB

    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
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: ScrollBar is not moving properly when I use TAB

    Do you use a scroll area or something like that? Could you provide more details?

  3. #3
    Join Date
    May 2007
    Posts
    16
    Thanked 1 Time in 1 Post

    Default Re: ScrollBar is not moving properly when I use TAB

    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...

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: ScrollBar is not moving properly when I use TAB

    Why should it scroll if you use tab?

  5. #5
    Join Date
    May 2007
    Posts
    16
    Thanked 1 Time in 1 Post

    Default Re: ScrollBar is not moving properly when I use TAB

    My question is Children widgets of ScrollArea is not shown properly when I use TAB.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: ScrollBar is not moving properly when I use TAB

    Did you implement that somehow? What about the tab order, does it work?

  7. #7
    Join Date
    May 2007
    Posts
    16
    Thanked 1 Time in 1 Post

    Default Re: ScrollBar is not moving properly when I use TAB

    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

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: ScrollBar is not moving properly when I use TAB


  9. #9
    Join Date
    May 2007
    Posts
    16
    Thanked 1 Time in 1 Post

    Default Re: ScrollBar is not moving properly when I use TAB

    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?

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: ScrollBar is not moving properly when I use TAB

    Do you need to check what? When you want a particular widget to be visible, just call this method with appropriate parametres.

  11. #11
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: ScrollBar is not moving properly when I use TAB

    Quote Originally Posted by chikkireddi View Post
    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?
    Are you sure the widget is a direct child of the scroll area?

  12. #12
    Join Date
    May 2007
    Posts
    16
    Thanked 1 Time in 1 Post

    Default Re: ScrollBar is not moving properly when I use TAB

    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

  13. #13
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: ScrollBar is not moving properly when I use TAB

    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

  14. #14
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: ScrollBar is not moving properly when I use TAB

    I don't know what's the actual problem here because QScrollArea already does ensure the child widget becomes visible:
    Qt Code:
    1. /*!
    2.   \reimp
    3.  */
    4. bool QScrollArea::focusNextPrevChild(bool next)
    5. {
    6. if (QWidget::focusNextPrevChild(next)) {
    7. if (QWidget *fw = focusWidget())
    8. ensureWidgetVisible(fw);
    9. return true;
    10. }
    11. return false;
    12. }
    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

  15. #15
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: ScrollBar is not moving properly when I use TAB

    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

  16. #16
    Join Date
    May 2007
    Posts
    16
    Thanked 1 Time in 1 Post

    Default Re: ScrollBar is not moving properly when I use TAB

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.