Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. SOLVED What signal to react on when QTabWidget is first displayed?
Forum Updated to NodeBB v4.3 + New Features

SOLVED What signal to react on when QTabWidget is first displayed?

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 4 Posters 654 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by Anonymous_Banned275
    #1

    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".

    2ec9089d-5159-4a66-ae8b-6baa0d924ecc-image.png

    JonBJ 1 Reply Last reply
    0
    • A Anonymous_Banned275

      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".

      2ec9089d-5159-4a66-ae8b-6baa0d924ecc-image.png

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @AnneRanch
      Usually when user clicks on tab you get currentChanged(int) signal, so that would be first thought. However, I am not sure whether you get this when QTabWidget shown for the first time, I don't know whether that generates a "tab changed" or not. So try on currentChanged and come back if that does not work?

      1 Reply Last reply
      1
      • A Offline
        A Offline
        Anonymous_Banned275
        wrote on last edited by
        #3

        @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.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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 ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Anonymous_Banned275
            wrote on last edited by
            #5

            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__);
            
            
            
            }
            
            
            
            
            
            
            
            
            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @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 ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • JoeCFDJ Offline
                JoeCFDJ Offline
                JoeCFD
                wrote on last edited by
                #7

                override the following func.
                protected:
                void showEvent(QShowEvent *) override;

                inside this func, you can query current tab index.

                A 1 Reply Last reply
                0
                • A Offline
                  A Offline
                  Anonymous_Banned275
                  wrote on last edited by
                  #8

                  I have a combo box in default tab and like to "fill it" from a text file.

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Why not do that in the constructor of that widget ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    A 1 Reply Last reply
                    1
                    • SGaistS SGaist

                      Why not do that in the constructor of that widget ?

                      A Offline
                      A Offline
                      Anonymous_Banned275
                      wrote on last edited by
                      #10

                      @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....

                      1 Reply Last reply
                      0
                      • JoeCFDJ JoeCFD

                        override the following func.
                        protected:
                        void showEvent(QShowEvent *) override;

                        inside this func, you can query current tab index.

                        A Offline
                        A Offline
                        Anonymous_Banned275
                        wrote on last edited by
                        #11

                        @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

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved