PDA

View Full Version : How to handle the value returned from a slot???



learner_qt
9th February 2013, 17:22
After every second I want to get the cursor position. But I dont know how to obtain the value returned from a slot???
Please help.
Thanks in advance! :)

Here is my code:




QTimer *mtimer = new QTimer();

connect (mtimer, SIGNAL(timeout()), this, SLOT (get_cursor_position()));

QPoint MainWindow::get_cursor_position()
{
q = QCursor::pos();
return q;
}

Zlatomir
9th February 2013, 17:51
The return value is ignored when the slot is executed by a connection (by emitting a signal) - it can be used only when you call the like any other member function.

Santosh Reddy
9th February 2013, 17:56
You could emit a signal from slot, like


QTimer *mtimer = new QTimer();

connect (mtimer, SIGNAL(timeout()), this, SLOT (get_cursor_position()));

QPoint MainWindow::get_cursor_position()
{
q = QCursor::pos();
emit cursorChanged(p);
}