0

I was following some code posted in other questions on how to connect the status bar between parent and distant child by means of signals and slots.

MainWindow::MainWindow(QWidget *parent) :
  QMainWindow(parent)
{
...
connect(myCanvas,SIGNAL(mouseMoved(QString)),
        this,slot(setStatusBar(QString)));
...
}

Somewhere in the class MainWindow the following is declared as public slot:

void MainWindow::setStatusBarText(const QString& text) {
statusBar()->showMessage(text);
}

in the class to which myCanvas belongs declares the signal:

signals:
void mouseMoved(const QString&);

And emits the signal:

void GraphicsView::mouseMoveEvent(QMouseEvent *mouseEvent)
{
 ...
     emit mouseMoved(QString("("+QString::number(mouseMoveCatch.x())+";"
        +QString::number(mouseMoveCatch.y())+")"));
 ...
 }

I am sure QString is properly included. But when i compile I get an error on the connect line saying "QString does not refer to a value". I have no clue what this means. Thanks for any help!

Francesco
  • 481
  • 2
  • 4
  • 16

1 Answers1

0

You have a case error on the line

connect(myCanvas,SIGNAL(mouseMoved(QString)),
    this,slot(setStatusBar(QString)));

You should be using SLOT, not slot.

RobbieE
  • 4,280
  • 3
  • 22
  • 36
  • Grrrr I feel really stupid for posting this. Thanks a lot. (my code still does not work though) – Francesco Mar 25 '14 at 20:48
  • If you're using Qt 5, you can avoid this kind of error by using the new connect syntax: `connect(myCanvas, &GraphicsView::mouseMoved, this, &MainWindow::setStatusBarText);` – RobbieE Mar 25 '14 at 20:50
  • I tried but (using 5.2) it gave a huge list of errors – Francesco Mar 25 '14 at 20:52
  • UPDATE: actually i tried again and see the new syntax works like a charm. I guess I made a typo there as well. Thanks a lot! – Francesco Mar 25 '14 at 20:53