标题:关于QTimer的问题,请指教,谢谢!
作者:jackyjun
日期:2006-05-19 16:35
内容:
我有一个关于QTimer的问题:
我现在用qt/e作一个仪器的界面,平常没有信号测试的时候,就在液晶界面上呈现随机的波形。我添加了一个定时器,50ms一个定时。等timeout()时,界面update()重画一场随机的波形。可是问题是,在程序运行的时候,发现波形是以1s为定时周期刷新的,而不是按照程序设定的50ms刷新的。我调整start(int msec)里的参数,发现改成2000后,波形就按照2s的周期刷新,而改成1000以下,无论什么数,波形始终按照1s的周期刷新。
请问大家,这是为什么呢?怎么样才能让我的随机波形以更快的速度刷新呢?
代码付下,请大家帮我看看,谢谢!
#include "mygui.h"
//#include "mymenu.h"
#include
#include
#include
#include
#include
#include
#include
#include
MyMainWindow::MyMainWindow()
{
screentimer = new QTimer(this);
setBackgroundColor(QColor(80,80,80));
setBackgroundMode(NoBackground);
setGeometry(0,0,320,240);
setupbutton = new QPushButton("Setup",this);
setupbutton->setGeometry(0,0,40,25);
setupmenu = new MyMenuSetup(this);
setupbutton->setPopup(setupmenu);
filebutton = new QPushButton("File",this);
filebutton->setGeometry(41,0,40,25);
filemenu = new MyMenuFile(this);
filebutton->setPopup(filemenu);
resultbutton = new QPushButton("Result",this);
resultbutton->setGeometry(82,0,40,25);
helpbutton = new QPushButton("Help",this);
helpbutton->setGeometry(123,0,40,25);
startTimer(0);
connect(screentimer,SIGNAL(timeout()),this,SLOT(repaint()));
screentimer->changeInterval(1);
screentimer->start(50); ..
#1 [jackyjun 05-22 09:17]
难道没有人回答么?请大家帮帮我吧!
#2 [jackyjun 05-22 15:58]
已解决,是paintEvent里面srand(time(NULL))的问题,去掉就好了!
#3 [ironner 05-22 22:02]
恭喜,楼主有QQ 没啊
#4 [ironner 05-22 22:03]
我一直关注你呢,可不可以把源代码都传上来让我们借鉴一下!
#5 [fengyuan1220 08-16 17:43]
我也是做这方面的开发,为什么不用QWT第三方控件呢,很方便,不过我还有些疑问,QQ250297124留下,有空可以交流