【发布时间】:2013-12-12 15:46:14
【问题描述】:
所以我有一个使用 GridLayout 创建的 GUI 应用程序。我制作了一堆 QLineEdit 小部件,这些小部件需要在新值出现时不断更新。最好和最有效的方法是什么?似乎是一个愚蠢的问题,但我在网上做了一些研究,似乎找不到最好和最有效的解决方案。提前致谢。
我尝试做 QTimer,它可以编译...但由于某种原因似乎永远不会超时(我在 run() 中有调试打印语句,它永远不会被打印。
time = new QLineEdit();
operationMode->setFixedWidth(150);
layout->addWidget(time, 4,7);
/*Test*/
qDebug() << "Here 1";
QTimer* timer = new QTimer(this);
timer->setSingleShot(false);
timer->setInterval(10 * 100); // 1 seconds
connect(timer, SIGNAL(timeout()), this, SLOT(run()));
setLayout(layout);
}
void MainWindow::run(void)
{
qDebug() << "Here 2";
time->setText(QTime::currentTime().toString());
qDebug() << "Here 3";
//qApp->processEvents();
}
【问题讨论】:
-
研究多线程。
-
你标题中“算法”的拼写错误有什么意义吗?