-1
A
回答
1
我會承擔這樣的事情,對於QTimer和繪畫之間的相互作用:
// Periodically paints a sinusoid on itself.
class SinPainter : public QWidget
{
Q_OBJECT
public:
SinPainter(QWidget *parent_p = NULL) :
QWidget(parent_p),
m_timer_p(new QTimer(this)),
m_t(0.0)
{
// When the timer goes off, run our function to change the t value.
connect(m_timer_p, SIGNAL(timeout()), SLOT(ChangeT()));
// Start the timer to go off every TIMER_INTERVAL milliseconds
m_timer_p->start(TIMER_INTERVAL);
}
// ...
protected slots:
void ChangeT()
{
// Change m_t to the new value.
m_t += T_INCREMENT;
// Calling update schedules a repaint event, assuming one hasn't
// already been scheduled.
update();
}
protected:
void paintEvent(QPaintEvent *e_p)
{
QPainter painter(this);
// Use painter and m_t to draw your current sinusoid according
// to your function.
}
private:
QTimer *m_timer_p;
double m_t; // <-- Or whatever variable type it needs to be.
};
相關問題
- 1. PyQt4:QPainter和QGraphicsSvgItem
- 2. Synchonizing睡眠和QTimer
- 3. QT5:與BitBlt到了QPainter ::的drawImage
- 4. 是什麼在了QPainter :: drawConvexPolgon點
- 5. QTimer,QThread的,和TCP消息
- 6. qtimer和opencv運行緩慢
- 7. QTimer和有效狀態
- 8. 瞭解QTimer用Lambda和遞歸函數調用
- 9. 我怎樣才能QTimer與QT QMainWindow QTimer(QTimer與QTWidget但不QMainWindow)
- 10. Qt初學者QPainter和QRect
- 11. 打印數據QTextDocument和QPainter
- 12. QPainter寬度和高度
- 13. QPainter :: drawLine和QPainter :: drawText在Qt中有不同的顏色問題
- 14. 帶QTimer的updateGL()
- 15. QPainter DrawImage CenterAligned
- 16. Qt - 創建QPainter
- 17. QEventLoop和QNAM的QTimer超時問題
- 18. 如何暫停和恢復Qtimer(Qt 5)
- 19. Qlabel和Qtimer(需要使圖像閃爍)
- 20. qpainter drawText文本方向和大小
- 21. 無法包含QTimer
- 22. QTimer與QDragEvent問題
- 23. QTimer動畫在QT
- 24. 公開QTimer。 (Qt,C++)
- 25. QPainter的drawLines方法
- 26. QPainter的QImage的到
- 27. 集QPainter的背景
- 28. 繪圖使用QPainter
- 29. 蟒蛇調整Qpainter
- 30. QPainter的不活躍
非常好,謝謝你。 – Hannibal 2009-12-09 20:35:56