Results 1 to 17 of 17

Thread: About QScroll Area

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    694
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    59
    Thanked 1 Time in 1 Post

    Default About QScroll Area

    Hi to all, I attached a widget to a QScrollArea. Such widget has a moving timeline. I would keep the timeline visible when moving,
    This mean that when the timeline come to the end of the widget the whole scrollarea should be shifted to the left. I don't know how to do it.

    I hope to get help.

    Best Regards,
    Franco
    Franco Amato

  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: About QScroll Area

    Set value of the horizontal scroll bar of the scroll area to 0.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    694
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    59
    Thanked 1 Time in 1 Post

    Default Re: About QScroll Area

    Quote Originally Posted by wysota View Post
    Set value of the horizontal scroll bar of the scroll area to 0.

    Hi it doesn't work...when the time line comes at the end of the viewport it disappear and nothing happens
    Franco Amato

  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: About QScroll Area

    Please provide a minimal compilable example reproducing the problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    694
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    59
    Thanked 1 Time in 1 Post

    Default Re: About QScroll Area

    Quote Originally Posted by wysota View Post
    Please provide a minimal compilable example reproducing the problem.
    Qt Code:
    1. WaveWidget::WaveWidget( QWidget* parent /* = 0 */ )
    2. : QWidget( parent ),
    3. m_wave(0),
    4. m_ZoomFactor( 1.0 )
    5. {
    6. /* scroll area */
    7.  
    8. sa->setWidgetResizable(true);
    9. QScrollBar *scrollBar = sa->horizontalScrollBar();
    10. scrollBar->setSliderDown( true );
    11. scrollBar->setValue(0);
    12. sa->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    13. sa->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    14.  
    15. m_WaveDisplay = new WaveDisplay(sa->viewport());
    16. m_WaveDisplay->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored);
    17. sa->setWidget( m_WaveDisplay );
    18.  
    19.  
    20. QHBoxLayout* hl = new QHBoxLayout();
    21. hl->addWidget(m_panel);
    22. hl->setSpacing( 0 );
    23. hl->addWidget(sa);
    24.  
    25. QVBoxLayout* layout = new QVBoxLayout();
    26. layout->addLayout(hl);
    27. layout->addLayout(lo);
    28. setLayout(layout);
    29. setFocusPolicy( Qt::TabFocus );
    30. }
    To copy to clipboard, switch view to plain text mode 

    m_WaveDisplay is a waveform display and when I click "play" a time line moves over it. When the timeline reach the end of the visible part it disappear on the right. I would shift the viewport() to keep visible ihe timeline.

    I hope it's clear
    Last edited by franco.amato; 23rd January 2010 at 20:08.
    Franco Amato

  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: About QScroll Area

    That's neither compilable nor reproducing the problem...

    Anyway, this works for me (and this is what I mean by a minimal compilable example):
    Qt Code:
    1. #include <QtGui>
    2.  
    3. class ScrollArea : public QScrollArea {
    4. public:
    5. ScrollArea() : QScrollArea(){}
    6. protected:
    7. void timerEvent(QTimerEvent *te){
    8. int v = horizontalScrollBar()->value();
    9. int m = horizontalScrollBar()->maximum();
    10. if(v==m)
    11. horizontalScrollBar()->setValue(0);
    12. else
    13. horizontalScrollBar()->setValue(v+1);
    14. }
    15. };
    16.  
    17. int main(int argc, char **argv){
    18. QApplication app(argc, argv);
    19. QLabel *label = new QLabel;
    20. QPixmap px(2048, 60);
    21. QLinearGradient grad(0,0,2048,0);
    22. grad.setColorAt(0, Qt::red);
    23. grad.setColorAt(1, Qt::blue);
    24. QPainter p(&px);
    25. p.fillRect(px.rect(), QBrush(grad));
    26. p.end();
    27. label->setPixmap(px);
    28. ScrollArea area;
    29. area.setWidget(label);
    30. area.show();
    31. area.startTimer(10);
    32. return app.exec();
    33. }
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    694
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    59
    Thanked 1 Time in 1 Post

    Thumbs up Re: About QScroll Area

    Quote Originally Posted by wysota View Post
    That's neither compilable nor reproducing the problem...

    Anyway, this works for me (and this is what I mean by a minimal compilable example):
    Qt Code:
    1. #include <QtGui>
    2.  
    3. class ScrollArea : public QScrollArea {
    4. public:
    5. ScrollArea() : QScrollArea(){}
    6. protected:
    7. void timerEvent(QTimerEvent *te){
    8. int v = horizontalScrollBar()->value();
    9. int m = horizontalScrollBar()->maximum();
    10. if(v==m)
    11. horizontalScrollBar()->setValue(0);
    12. else
    13. horizontalScrollBar()->setValue(v+1);
    14. }
    15. };
    16.  
    17. int main(int argc, char **argv){
    18. QApplication app(argc, argv);
    19. QLabel *label = new QLabel;
    20. QPixmap px(2048, 60);
    21. QLinearGradient grad(0,0,2048,0);
    22. grad.setColorAt(0, Qt::red);
    23. grad.setColorAt(1, Qt::blue);
    24. QPainter p(&px);
    25. p.fillRect(px.rect(), QBrush(grad));
    26. p.end();
    27. label->setPixmap(px);
    28. ScrollArea area;
    29. area.setWidget(label);
    30. area.show();
    31. area.startTimer(10);
    32. return app.exec();
    33. }
    To copy to clipboard, switch view to plain text mode 
    Dear Wysota I solved my problem using ensureVisible routine of the QScrollArea http://doc.trolltech.com/4.6/qscroll...#ensureVisible givind periodically the position of the timeline and it works perfectly.
    This routine is fantastic!!

    Best Regards
    Franco Amato

  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: About QScroll Area

    That's the second time you "solved" your problem the wrong way. Keep doing that and at some point everything will fall apart.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    694
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    59
    Thanked 1 Time in 1 Post

    Default Re: About QScroll Area

    Quote Originally Posted by wysota View Post
    That's the second time you "solved" your problem the wrong way. Keep doing that and at some point everything will fall apart.
    Why wrong way? Seems work well. I don't have to set to zero the scroll bar, I would keep visible the timeline
    Franco Amato

  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: About QScroll Area

    Quote Originally Posted by franco.amato View Post
    Why wrong way? Seems work well.
    Many things seem well but you shouldn't use them as at some point the combination of things that seem to work fell will blow up into your face.

    I don't have to set to zero the scroll bar,
    Honestly, you don't have to do anything...

    I would keep visible the timeline
    Did you run my example? Did you see the gradient vanishing after reaching the end? Maybe things are already exploding in your face...
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    694
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    59
    Thanked 1 Time in 1 Post

    Default Re: About QScroll Area

    Sorry but nothing is exploding in my face and yes I run your example.
    I think you should speak in a different way as administrator without ridicole the work of other developers.
    Maybe I'm not a Qt expert, my field is another and if I ask for help here is to learn and improve my Qt.

    Best Regards
    Franco Amato

Similar Threads

  1. About visual area
    By calmspeaker in forum Qt Programming
    Replies: 0
    Last Post: 16th March 2009, 13:14
  2. Replies: 19
    Last Post: 26th November 2008, 19:54
  3. Qt From Without Title area
    By nleverin in forum Newbie
    Replies: 3
    Last Post: 7th March 2008, 06:45
  4. scroll area like QGraphicsItem
    By Gopala Krishna in forum Qt Programming
    Replies: 1
    Last Post: 7th February 2008, 11:28
  5. select a particular area
    By vishesh in forum Qt Programming
    Replies: 4
    Last Post: 28th February 2007, 21:44

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.