SOLVED What signal to react on when QTabWidget is first displayed?
-
As a result of MDI menu selection I run QTabWidget.
I would like to process default tab without user interaction.
Is there a signal I can detect such as "default tab activated " ?
I can probably figure out how to detect the MDI signal, but do not see how to detect "default tab" activated". -
@AnneRanch
Usually when user clicks on tab you getcurrentChanged(int)
signal, so that would be first thought. However, I am not sure whether you get this whenQTabWidget
shown for the first time, I don't know whether that generates a "tab changed" or not. So try oncurrentChanged
and come back if that does not work? -
@JonB said in What signal to react on when QTabWidget is first displayed?:
currentChanged(int)
Yes, that is emitted when tab is changed using mouse.
I 'll looking into MDI signals. -
Hi,
There's no such signal. That's typically a use case that you need to implement yourself.
Can you describe what exactly you do with that menu and how it is related to the QTabWidget ?
-
Here is the menu code creating the form.
I think one way to create "signal" could be
FW->activateWindow();I am working in that...
Definitely not "out of the box" process..,
The task is to at least fill ONE widget in the default tab.I have it working manually - using button push.
The idea is to automate it when the default tab is activated.
I know I can option which tab will be set as default - maybe I can use that...void MainWindow::Run_HCI(void) { qDebug() << "\nTASK : " << "\nCreate START child as QMdiSubWindow \n" << "\nFile : " << (__FILE__) << "\nFunction : " << (__FUNCTION__) << "\n@line : " <<(__LINE__); //MdiChild_ORIGINAL *child = createMdiChild(); //child->show(); // duplicate Form_Widget Nov 3 did noit work - need build from scrach // Form_Widget *FW = new Form_Widget(); Form_Widget_HCI *FW = new Form_Widget_HCI(); //FW->ui. //FW->activateWindow(); QRect dimensions = FW->geometry(); int x = dimensions.height(); int y = dimensions.width(); //HERE //int start_X = dimensions.x2; //QMdiArea mdiArea; reusing child QMdiSubWindow *child = new QMdiSubWindow(FW); //subWindow1->setWidget(internalWidget1); child->setAttribute(Qt::WA_DeleteOnClose); child->setWindowTitle(__FILE__); // add to main area mdiArea->addSubWindow(child); // adjust subwindow size to display just TAB plus someting //QRect dimensions = FW->geometry(); // void QRect::getCoords(int *x1, int *y1, int *x2, int *y2) const //QPoint QRect::bottomRight() const #ifdef BYPASS @AnneRanch void QRect::getCoords(int *x1, int *y1, int *x2, int *y2) const QPoint QRect::bottomRight() const & int QPoint::x() const #endif // QString height = FW->tab_height.toNumber(); // qDebug(height); // Temp MN QTTab // child->setFixedHeight(1000); // child->setFixedHeight(1000); // QRect dimensions = FW->geometry(); // int start_X = dimensions.x2; int test = FW->tab_height/20000/100; child->setFixedHeight(test ); // FW->tab_height/20000); child->setFixedHeight(x -100 ); //display outside TAB (?) child->setFixedWidth(y) ; // activate widget child->setWidget(FW); child->showNormal(); qDebug() << "\nTASK : " << "\nCreate END child as QMdiSubWindow \n" << "\nFile : " << (__FILE__) << "\nFunction : " << (__FUNCTION__) << "\n@line : " <<(__LINE__); }
-
@AnneRanch said in What signal to react on when QTabWidget is first displayed?:
Form_Widget_HCI
Is that the widget you are talking about ?
What kind of initialisation do you want to do ? -
I have a combo box in default tab and like to "fill it" from a text file.
-
Why not do that in the constructor of that widget ?
-
@SGaist said in What signal to react on when QTabWidget is first displayed?:
Why not do that in the constructor of that widget ?
SOLVED
Purfect, you get a gold star.... -
@JoeCFD said in What signal to react on when QTabWidget is first displayed?:
override the following func.
protected:
void showEvent(QShowEvent *) override;inside this func, you can query current tab index.
Maybe I can modify this to solve my other issue.
Thanks