I have a simple setup to change a label on a timed interval, for testing purposes. It seems that the signal does not ever get emitted. I’m using Visual Studio 2010 with the Qt add-in. Here is my setup…
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();
}
And in the header file,
public:
Window(QWidget *parent = 0, Qt::WFlags flags = 0);
~Window();
public slots:
void nextFrame();
private:
Ui::TrackerClass ui;
QTimer *timer;
};
Why is the slot nextFrame() never being triggered?
There is nothing in this code which calls
start()and so based on this codenextFrame()would never be triggered bytimeout().