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. QTabWidget pages OnSetActive()?
Forum Updated to NodeBB v4.3 + New Features

QTabWidget pages OnSetActive()?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 511 Views 1 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.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by
    #1

    I'm converting some MFC code that uses tabbed dialogs implemented using CPropertySheet and CPropertyPage.

    This code makes use of the CPropertyPage::OnSetActive() method which is invoked when the individual tab is made the active tab This code can't be placed in the ctor in most cases as it depends on the actual conditions at the time the tab is activated.

    I've been digging through the documentation to try to find the equivalent of this in Qt, but so far haven't come up with anything.

    Please could someone take pity on a Qt beginner and point me to the relevant docs/samples.

    Thanks
    David

    JonBJ 1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on last edited by
      #2

      I don't know about this method.
      But from you description, I feel it similar to the signal of QTabWidget

      void  currentChanged(int index)
      

      If it is not, can you describe more about how do you need to use it?

      PerdrixP 1 Reply Last reply
      2
      • PerdrixP Offline
        PerdrixP Offline
        Perdrix
        wrote on last edited by Perdrix
        #3

        Thanks Bonnie I'll take a look at that. Further digging suggests that this:

        void MyDialogue::showEvent(QShowEvent *event)
        {
        	if (!event->spontaneous())
                {
                    // Do stuff here
                }
        
               // Invoke base class showEvent()
              return QDialog::showEvent(event);
        }
        

        might also be relevant.

        David

        1 Reply Last reply
        1
        • PerdrixP Perdrix

          I'm converting some MFC code that uses tabbed dialogs implemented using CPropertySheet and CPropertyPage.

          This code makes use of the CPropertyPage::OnSetActive() method which is invoked when the individual tab is made the active tab This code can't be placed in the ctor in most cases as it depends on the actual conditions at the time the tab is activated.

          I've been digging through the documentation to try to find the equivalent of this in Qt, but so far haven't come up with anything.

          Please could someone take pity on a Qt beginner and point me to the relevant docs/samples.

          Thanks
          David

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

          @Perdrix
          Depending on how it's supposed to work, @Bonnie's currentChanged() may be what you need. But I found I needed to use QApplication::focusChanged() --- or you could use individual page's "focus" event if you are sub-classing --- to get correct signal for some purposes, You may need to look at both. I'm not sure.

          1 Reply Last reply
          0
          • B Bonnie

            I don't know about this method.
            But from you description, I feel it similar to the signal of QTabWidget

            void  currentChanged(int index)
            

            If it is not, can you describe more about how do you need to use it?

            PerdrixP Offline
            PerdrixP Offline
            Perdrix
            wrote on last edited by
            #5

            @Bonnie said in QTabWidget pages OnSetActive()?:

            I don't know about this method.
            But from you description, I feel it similar to the signal of QTabWidget

            void  currentChanged(int index)
            

            If it is not, can you describe more about how do you need to use it?

            That might work but seems a little roundabout requiring each individual sub-dialogue to have a slot for that signal and then work out if it applies to them?

            D.

            B 1 Reply Last reply
            0
            • PerdrixP Perdrix

              @Bonnie said in QTabWidget pages OnSetActive()?:

              I don't know about this method.
              But from you description, I feel it similar to the signal of QTabWidget

              void  currentChanged(int index)
              

              If it is not, can you describe more about how do you need to use it?

              That might work but seems a little roundabout requiring each individual sub-dialogue to have a slot for that signal and then work out if it applies to them?

              D.

              B Offline
              B Offline
              Bonnie
              wrote on last edited by
              #6

              @Perdrix I googled OnSetActive, seems that it should be implemented in every tab page?
              So you mean if you use currentChanged, you will need to create a slot for every page and connect the signal to them?
              I don't think this is a good way. Maybe you can look at @JonB 's focus event stuff.

              I also have another thought, a bit complicated.
              You can define a public slot named OnSetActive in every page.
              And you connect currentChanged to a slot in which you get the current page and invoke its OnSetActive slot by

              if(QWidget* widget = tabWidget->currentWidget())
                  QMetaObject::invokeMethod(widget, "OnSetActive");
              
              1 Reply Last reply
              1
              • PerdrixP Offline
                PerdrixP Offline
                Perdrix
                wrote on last edited by Perdrix
                #7

                @Bonnie said in QTabWidget pages OnSetActive()?:

                QMetaObject::invokeMethod(widget, "OnSetActive");

                Ooh! Sneaky - I much prefer that to handling Show Events.

                So long as the currentChanged(int tab) signal is emitted for the first tab that is auto-selected ...

                I'll give it a try! Though it will be some days before I can run the code (huge editing task in hand).

                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