Results 1 to 5 of 5

Thread: qscrollarea slider problem

  1. #1
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default qscrollarea slider problem

    hi
    i have a qlabel whose parent is qscrollarea. i have subclassed the qlabel to receive mouse move events.

    whwnever the label(contains image) is moved using mouse (click and then move)
    the label inside qscrollarea moves. but the scrollbars are not moving with respect to qlabel.

    how to update the scrollbars with respect to qlabel movement.

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

    Default Re: qscrollarea slider problem

    Could we see some code? The event handler at least...

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

    Default Re: qscrollarea slider problem

    You'll need a container widget which is the parent of the movable label. This container widget must automatically grow when label is moved outside its boundaries. This container widget is then set inside the scroll area with QScrollArea::setWidget(). However, there are certain problems with this approach I don't have time to explain right now. Save yourself some time and use QMdiArea with frameless sub windows.
    J-P Nurmi

  4. #4
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default Re: qscrollarea slider problem

    Could we see some code?
    sure


    Qt Code:
    1. void iv_isa::mousePressEvent ( QMouseEvent * event )
    2. {
    3. QPoint mouse_event_distance
    4. mouse_event_distance = mapToParent(event->pos()) - this->pos();
    5. }
    6.  
    7. void IV_label::mouseMoveEvent ( QMouseEvent * event )
    8. {
    9. this->move(mapToParent(event->pos()) - mouse_event_distance);
    10. }
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: qscrollarea slider problem

    Does the scroll area contain anything else or just the label? Because if it contains just the label, use QMdiArea as suggested. If it contains some other elements, use QGraphicsView.

Similar Threads

  1. QSlider problem
    By sincnarf in forum Qt Programming
    Replies: 1
    Last Post: 10th October 2007, 01:07
  2. QScrollArea and resizing
    By rarefluid in forum Qt Programming
    Replies: 8
    Last Post: 22nd July 2007, 14:18
  3. Replies: 2
    Last Post: 8th October 2006, 20:14
  4. QScrollArea problem positioning a QWidget inside
    By Spectator in forum Qt Programming
    Replies: 4
    Last Post: 20th February 2006, 22:59
  5. Problem with QScrollArea updating from 4.0.1 to 4.1.0
    By SkripT in forum Qt Programming
    Replies: 8
    Last Post: 28th January 2006, 22:35

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.