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. Help with QWidget::show()

Help with QWidget::show()

Scheduled Pinned Locked Moved Solved General and Desktop
showeventshow
17 Posts 5 Posters 4.8k Views
  • 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.
  • mmikeinsantarosaM Offline
    mmikeinsantarosaM Offline
    mmikeinsantarosa
    wrote on last edited by
    #3

    @Christian-Ehrlicher said in Help with QWidget::show():

    void ChartProperties::showEvent(QShowEvent *ev)

    I get "extra qualification on member 'showEvent'"

    1 Reply Last reply
    0
    • mmikeinsantarosaM Offline
      mmikeinsantarosaM Offline
      mmikeinsantarosa
      wrote on last edited by
      #4

      And the widget is actually a "QDialog".

      1 Reply Last reply
      0
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #5

        And please show how you defined and declared this function.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        0
        • mmikeinsantarosaM Offline
          mmikeinsantarosaM Offline
          mmikeinsantarosa
          wrote on last edited by
          #6

          Realizing that the class is actually a QDialog so I just changed the declaration to
          virtual void showEvent(QShowEvent *event) override;
          and it doesn't complain now.

          So now, how do I hook it up to execute another function?
          Right clicking on it and selecting refactor doesn't provide a way to create a function in my source. Do I need to create a slot to connect it to?

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #7

            @mmikeinsantarosa said in Help with QWidget::show():

            So now, how do I hook it up to execute another function?

            I don't understand this question. Simply create a function in your class and call it from within your other function.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            0
            • mmikeinsantarosaM Offline
              mmikeinsantarosaM Offline
              mmikeinsantarosa
              wrote on last edited by mmikeinsantarosa
              #8

              Sorry, I'm feeling pretty dumb here.

              Another class executes the ChartProperties->Show() method and when the dialog is rendered, I want to trap the ChartProperties show() event.
              I have irtual void showEvent(QShowEvent *event) override;
              in my ChartProperties header but I don't understand how to receive the showEvent..

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

                As explained in the documentation this function is called when the widget is shown, you must not call it by yourself.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                1 Reply Last reply
                0
                • mmikeinsantarosaM mmikeinsantarosa

                  Sorry, I'm feeling pretty dumb here.

                  Another class executes the ChartProperties->Show() method and when the dialog is rendered, I want to trap the ChartProperties show() event.
                  I have irtual void showEvent(QShowEvent *event) override;
                  in my ChartProperties header but I don't understand how to receive the showEvent..

                  SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #10

                  Hi,

                  @mmikeinsantarosa said in Help with QWidget::show():

                  I have irtual void showEvent(QShowEvent *event) override;

                  This is just a declaration, you still have to implement the function itself.

                  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
                  • mmikeinsantarosaM Offline
                    mmikeinsantarosaM Offline
                    mmikeinsantarosa
                    wrote on last edited by
                    #11

                    Do I create a slot then connect this event to my slot?

                    M 1 Reply Last reply
                    0
                    • Christian EhrlicherC Offline
                      Christian EhrlicherC Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by
                      #12

                      @mmikeinsantarosa said in Help with QWidget::show():

                      Do I create a slot then connect this event to my slot?

                      What slot? showEvent() is a class function, not a slot. Please learn C++ basics first.

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      1 Reply Last reply
                      1
                      • mmikeinsantarosaM mmikeinsantarosa

                        Do I create a slot then connect this event to my slot?

                        M Offline
                        M Offline
                        mpergand
                        wrote on last edited by mpergand
                        #13

                        @mmikeinsantarosa

                        Your question seems pretty close this this one

                        As an alternative, you can simply do:

                        MyDialog::show()
                        {
                          myFunction();
                          QDialog::show();
                        }
                        

                        Using showEvent is dangerous cause it can be called multi times !

                        1 Reply Last reply
                        0
                        • mmikeinsantarosaM Offline
                          mmikeinsantarosaM Offline
                          mmikeinsantarosa
                          wrote on last edited by
                          #14

                          The method name is "showEvent" which leads me to think it's a signal. It's also listed in the signals list in the documentation for QDialog so I thought it might actually be a signal.

                          thanks for clearing this up SGaist.

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

                            @mmikeinsantarosa said in Help with QWidget::show():

                            It's also listed in the signals list in the documentation for QDialog

                            That's wrong, neither in the Qt 5 nor in the Qt 6 documentation.

                            It is listed under Reimplemented Protected Functions.

                            Beside that, signals name do not finish in "event". They usually have a name in relation to some action like rejected in QDialog.

                            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
                            1
                            • mmikeinsantarosaM Offline
                              mmikeinsantarosaM Offline
                              mmikeinsantarosa
                              wrote on last edited by
                              #16

                              I stand corrected. entering QDialog in the Qt help and selecting signals reveals signals at the top, with 3 items under it then Reimplemented Protected Functions where the showEvent function is listed.

                              JonBJ 1 Reply Last reply
                              0
                              • mmikeinsantarosaM mmikeinsantarosa

                                I stand corrected. entering QDialog in the Qt help and selecting signals reveals signals at the top, with 3 items under it then Reimplemented Protected Functions where the showEvent function is listed.

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

                                @mmikeinsantarosa
                                Indeed, that is how Qt documentation lays out its methods.

                                To reiterate something @Christian-Ehrlicher said. In Qt nomenclature:

                                • Methods ending in Event (showEvent(), mouseMoveEvent()) are not signals. Instead they are protected virtual methods. You must sub-class and override if you want to access them.

                                • Signals tend to be named as the past tense of something that has happened (clicked(), customContextMenuRequested()). You cannot override them. You can connect() to them, without needing to sub-class.

                                • And slots are just named as an action to be performed (show(), setDiabled()).

                                1 Reply Last reply
                                1

                                • Login

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