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:

Qt Code:
  1. //I have a class like this:
  2. class myC : public QWidget
  3. {
  4. //...
  5. public:
  6. void myfunction(); // this is what I want to reach
  7. }
  8.  
  9. //this is in the mainWindow class somewhere:
  10. //I made the stackedwidget in the code, say with the name myStackedWidget
  11. myStackedWidget->setCurrentIndex(i); //shows the wanted widget correctly
  12.  
  13. //and here I need to access the current widget that is shown
  14.  
  15. 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?