Hi,
I have a QSteckedWidget on my gui and I put my own widgets on it, showing the actual one depending on some choices made on the other parts of the gui. I can set this with QStackedWidget::setCurrentIndex().
Now I need the reverse: I would like to use some functions that belong to the current widget. here is some pseudo-code:
//I have a class like this:
{
//...
public:
void myfunction(); // this is what I want to reach
}
//this is in the mainWindow class somewhere:
//I made the stackedwidget in the code, say with the name myStackedWidget
myStackedWidget->setCurrentIndex(i); //shows the wanted widget correctly
//and here I need to access the current widget that is shown
myStackedWidhet->currentWidget(i)->myfunction();//does not work
//I have a class like this:
class myC : public QWidget
{
//...
public:
void myfunction(); // this is what I want to reach
}
//this is in the mainWindow class somewhere:
//I made the stackedwidget in the code, say with the name myStackedWidget
myStackedWidget->setCurrentIndex(i); //shows the wanted widget correctly
//and here I need to access the current widget that is shown
myStackedWidhet->currentWidget(i)->myfunction();//does not work
To copy to clipboard, switch view to plain text mode
the error message says:
"class QWidget has no member named 'myfunction()'"
This shows that what I can get with this function is a Widget, but not the myC. How can I solve this?
Bookmarks