So, I've been working on my GUI and it's gotten pretty large, so I decided to split it into multiple widgets that communicate with the main window (probably something that I should have done from the beginning). I've partitioned part of my GUI into a separate widget, but I'm having trouble setting up signals and slots between the main window and the new widget, and I was hoping you could help me figure out what I'm doing wrong.
The main window is called robotmainwindow and the widget is called robotTabWidget. In robotmainwindow.h, I forward declared robotTabWidget as such:
robotTabWidget* robotttabwidget;
Then, in robotmainwindow.cpp, I initialized the class:
robottabwidget = new robotTabWidget();
I have function called create connections in robotmainwindow, in which I try to connect a signal from robotTabWidget to a slot in robotmainwindow:
void robotmainwindow::createConnections()
{
connect(robottabwidget, &robotTabWidget::sigSendCartCommand, this, &robotmainwindow::slotOnSendCartCommand);
}
The signal sigSendCartCommand is defined in robottabwidget.h:
void sigSendCartCommand(double);
And emitted in robotTabWidget::on_SendCartCommand_clicked():
emit sigSendCartCommand(CartCommand);
But when I attempt to compile, I get a "no matching function for call to" for the connect function, and "robotTabWidget::sigSendCartCommand(double) is protected". Why is the signal protected? I thought you could emit a signal from anywhere. And why am I getting a "no matching function" error?
This has been giving me a lot of trouble for the last few days and I haven't been able to figure it out. I'd greatly appreciate your help!
edit: I've changed things around, and fixed a few things but I'm still getting errors. The connect function now looks like:
QObject::connect(myrobotTabWidget, robotTabWidget::sigTest(test), this, &robotmainwindow::slotOnSendCartCommand);
The error I'm now getting is "cannot call member function without object":
../RobotInterface2/robotmainwindow.cpp:102:68: error: cannot call member function 'void robotTabWidget::sigTest(QString)' without object
QObject::connect(myrobotTabWidget, robotTabWidget::sigTest(test), this, &robotmainwindow::slotOnSendCartCommand);
And the arrow is pointing at robotTabWidget::sigTest(QString). I'm not sure what to do about this. Any ideas?