Please provide a minimal compilable example reproducing the problem.
Qt Code:
m_wave(0), m_ZoomFactor( 1.0 ) { /* scroll area */ sa->setWidgetResizable(true); scrollBar->setSliderDown( true ); scrollBar->setValue(0); sa->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); sa->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); m_WaveDisplay = new WaveDisplay(sa->viewport()); sa->setWidget( m_WaveDisplay ); hl->addWidget(m_panel); hl->setSpacing( 0 ); hl->addWidget(sa); layout->addLayout(hl); layout->addLayout(lo); setLayout(layout); setFocusPolicy( Qt::TabFocus ); }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
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:
#include <QtGui> public: protected: int v = horizontalScrollBar()->value(); int m = horizontalScrollBar()->maximum(); if(v==m) horizontalScrollBar()->setValue(0); else horizontalScrollBar()->setValue(v+1); } }; int main(int argc, char **argv){ grad.setColorAt(0, Qt::red); grad.setColorAt(1, Qt::blue); p.end(); label->setPixmap(px); ScrollArea area; area.setWidget(label); area.show(); area.startTimer(10); return app.exec(); }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
That's the second time you "solved" your problem the wrong way. Keep doing that and at some point everything will fall apart.
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.
Honestly, you don't have to do anything...I don't have to set to zero the scroll bar,
Did you run my example? Did you see the gradient vanishing after reaching the end? Maybe things are already exploding in your face...I would keep visible the timeline
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
If things that are working for me are not working for you then the only thing to blame is the code already in your application.
Did it work? Did you adapt it to your application? Did it work there?and yes I run your example.
This forum is here mainly to help others and not to praise their work, be it good or bad.I think you should speak in a different way as administrator without ridicole the work of other developers.
So learn and improve instead of going forward the wrong path even if someone is constrantly trying to pull you away from it.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.
You can abuse some mechanisms in Qt and they will work. But at some point you reach a situation when the side effects of all the abuses get stacked and accumulate effectively preventing you from finishing your task successfully. The rules of Software Engineering say that the latter you spot the problem, withdraw from it and do things the proper way, the more expensive it is.
I didn't say that it doesn't work, I said that I don't need it also if your example is very good. Maybe my english sometime is not perfect.
Yes it works. In the attached widget I already have a timer that move a timeline so the routine used by me seems perfect for my purpose.Did it work? Did you adapt it to your application? Did it work there?
Johan Thelin suggested it to me.
If this routine is so bad, why it exists? Seems done for my purposeThis forum is here mainly to help others and not to praise their work, be it good or bad.
So learn and improve instead of going forward the wrong path even if someone is constrantly trying to pull you away from it.
You can abuse some mechanisms in Qt and they will work. But at some point you reach a situation when the side effects of all the abuses get stacked and accumulate effectively preventing you from finishing your task successfully. The rules of Software Engineering say that the latter you spot the problem, withdraw from it and do things the proper way, the more expensive it is.
Franco Amato
I don't see how using ensureVisible() is more "perfect" than setting the value of the scroll bar to 0 but have it your way...
"If division by 0 is a bad thing then why does division exist at all?"If this routine is so bad, why it exists? Seems done for my purpose
In other words, I didn't say the routine is bad, I said it's bad in your case (actually it's not that bad in this situation but once you start adding more functionality it might become bad).
Last edited by wysota; 26th January 2010 at 17:06.
Why should I set the value to zero? I have to keep visible the timeline ( in my case a moving line from left to right ) that disappear in the right size of the widget when I resize it ( while playing a sound )
I think you didn't understand my scenario, sure for my bad english sorry.
"If division by 0 is a bad thing then why does division exist at all?"
In other words, I didn't say the routine is bad, I said it's bad in your case (actually it's not that bad in this situation but once you start adding more functionality it might become bad)
Best Regards
Franco Amato
Bookmarks