Lets say there are 3 classes Foo1
, Foo2
and Foo3
. They are inherit QWidget
. I now place each of them info a QTabWidget
object.
QWidget* foo1 = new Foo1();
ui->tbMain->addTab(foo1, "Untitled*");
QWidget* foo2 = new Foo2();
ui->tbMain->addTab(foo2, "Untitled*");
QWidget* foo3 = new Foo3();
ui->tbMain->addTab(foo3, "Untitled*");
Now I select different tabs and a signal is emited and this slot catches it:
void MainWindow::on_tbMain_currentChanged(int index)
{
QWidget* widget = ui->tbMain->widget(index);
}
I can retrieve the object that is in the currently selected tab. But i can retrieve it as QWidget
, and I need to know either it is type Foo1
, Foo2
or Foo3
? How can I do that? I would apreciate all help!