Some questions about loop in QWidget
-
Hi, can you tell us your requirments ? I don't think that the things can be done in while loop in GUI thread can not be achieved with QTimer. And I also notice that you called repaint() manully, which seems not a good idea too.
-
[quote author="1+1=2" date="1375081773"]Hi, can you tell us your requirments ? I don't think that the things can be done in while loop in GUI thread can not be achieved with QTimer. And I also notice that you called repaint() manully, which seems not a good idea too.
[/quote]
i want refresh screen with precision.
-
You mean that you have tried following things and find they don't meet your requirments?
- QTimer instead of while-loop
- update() instead of repaint()
-
[quote author="1+1=2" date="1375083260"]You mean that you have tried following things and find they don't meet your requirments?
- QTimer instead of while-loop
- update() instead of repaint()[/quote]
thank you help
QTimer is not so precision
update i will try...
-
Yes, QTimer is not so precision.
But afaik, you can not make it accurate with your following code too.
@
while(on)
{
...
repaint();
QApplication::processEvents();
}
@ -
[quote author="1+1=2" date="1375086205"]Yes, QTimer is not so precision.
But afaik, you can not make it accurate with your following code too.
@
while(on)
{
...
repaint();
QApplication::processEvents();
}
@[/quote]you mean... processEvents may causes delay?
-
Yes, there are so many things needed to do by it, such as mousePressEvent/mouseMoveEvent/resizeEvent/closeEvent/...
-
[quote author="1+1=2" date="1375152030"]Yes, there are so many things needed to do by it, such as mousePressEvent/mouseMoveEvent/resizeEvent/closeEvent/...[/quote]
do you have any better ways?
-
[quote author="1+1=2" date="1375152030"]Yes, there are so many things needed to do by it, such as mousePressEvent/mouseMoveEvent/resizeEvent/closeEvent/...[/quote]
can i set events' priority for reflashing screen immediately?
-
What precision do you need?
[quote author="eiao" date="1375152344"]can i set events' priority for reflashing screen immediately?[/quote]You can set event priorities (see "Qt::EventPriority":http://qt-project.org/doc/qt-5.1/qtcore/qt.html#EventPriority-enum and "QCoreApplication::postEvent()":http://qt-project.org/doc/qt-5.1/qtcore/qcoreapplication.html#postEvent). But, high-priority events can only "jump queue" if the other events are still waiting to be processed. They cannot interrupt an event that has already started getting processed.
If your application has already started processing a low-priority event when a high-priority event arrives, your new high-priority event must still wait for the first one to finish.