Hi Chris,
I think I am getting closer, but I am stuck with this error:
error: expected primary-expression before ‘,’ token
error: expected primary-expression before ‘,’ token
To copy to clipboard, switch view to plain text mode
which means that I am probably doing something very wrong connecting signal/slot.
In the constructor of otherWidget (I call it MyWidget)
//connect(mySlider, SIGNAL(valueChanged(int)), this, SIGNAL( sendInfoToMainWindows(int) ));
connect(mySlider, SIGNAL(valueChanged(int)), this, SLOT( sendInfoToMainWindows(int) ));
connect( MyWidget, SIGNAL( sendInfoToMainWindows(int) ), MainWindow, SLOT( printNumberInfoToStatusBar(int) ) );//error!!!
mySlider = new QSlider;
//connect(mySlider, SIGNAL(valueChanged(int)), this, SIGNAL( sendInfoToMainWindows(int) ));
connect(mySlider, SIGNAL(valueChanged(int)), this, SLOT( sendInfoToMainWindows(int) ));
connect( MyWidget, SIGNAL( sendInfoToMainWindows(int) ), MainWindow, SLOT( printNumberInfoToStatusBar(int) ) );//error!!!
To copy to clipboard, switch view to plain text mode
I tried without success to put the connection line in the MainWindow.cpp
widget = new MyWidget;
setCentralWidget(widget);
connect( widget, SIGNAL( sendInfoToMainWindows(int) ), MainWindow, SLOT( printNumberInfoToStatusBar(int) ) );
widget = new MyWidget;
setCentralWidget(widget);
connect( widget, SIGNAL( sendInfoToMainWindows(int) ), MainWindow, SLOT( printNumberInfoToStatusBar(int) ) );
To copy to clipboard, switch view to plain text mode
I know the emit function is wrong, but I just want to emit the value that the slider sends to the MyWidget
void MyWidget::sendInfoToMainWindows(int value)
{
emit value;
}
void MyWidget::sendInfoToMainWindows(int value)
{
emit value;
}
To copy to clipboard, switch view to plain text mode
I sorted out the mainWindow message function to accept integers:
void MainWindow::printNumberInfoToStatusBar (int value)
{
str.setNum(value);
statusBar()->showMessage(str);
}
void MainWindow::printNumberInfoToStatusBar (int value)
{
QString str;
str.setNum(value);
statusBar()->showMessage(str);
}
To copy to clipboard, switch view to plain text mode
Any ideas?~!
Added after 10 minutes:
well, it is this magic effect when you press the post button of the forum, you get a new idea and things work better.
The connection SHOULD be in the MainWindow.cpp
widget = new MyWidget;
setCentralWidget(widget);
connect( widget, SIGNAL( sendInfoToMainWindows(int) ), this, SLOT( printNumberInfoToStatusBar(int) ) );
widget = new MyWidget;
setCentralWidget(widget);
connect( widget, SIGNAL( sendInfoToMainWindows(int) ), this, SLOT( printNumberInfoToStatusBar(int) ) );
To copy to clipboard, switch view to plain text mode
everything compiles, but now I have to find the right syntax to emit the value that the MYWidget gets from the slide to the MainWindow
void MyWidget::sendInfoToMainWindows(int value)
{
emit value;
}
void MyWidget::sendInfoToMainWindows(int value)
{
emit value;
}
To copy to clipboard, switch view to plain text mode
Bookmarks