1
为了测试目的,我有一个简单的设置来在定时间隔上更改标签。看起来信号并没有发射出去。我正在使用Visual Studio 2010和Qt插件。这里是我的设置...QTimer不以建议的时间间隔发射信号
Window::Window(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
my_label = new QLabel();
timer = new QTimer(this);
timer->setInterval(1000);
connect(timer, SIGNAL(timeout()), this, SLOT(nextFrame()));
}
void Window::nextFrame()
{
static int i = 0;
std::stringstream ss;
ss << "C:/files/" << i << ".txt";
QString qstr = QString::fromStdString(ss.str());
ui.label->setText(qstr);
ss.str("");
i++;
repaint();
}
而且在头文件,
public:
Window(QWidget *parent = 0, Qt::WFlags flags = 0);
~Window();
public slots:
void nextFrame();
private:
Ui::TrackerClass ui;
QTimer *timer;
};
为什么插槽nextFrame()
从未被触发?
就是这样。 D'哦!我正在按照教程,错过了:)谢谢 – zebra