Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved mouseDoubleClickEvent minor problem (pointers and variable as Argument of function)

    General and Desktop
    3
    6
    498
    Loading More Posts
    • 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.
    • F
      Faruq last edited by

      Hi everyone, just a short problem for today. While playing around with mouseDoubleClickEvent (To execute close()), I would like to put in variable as argument into this function. But it doesn't work (As if it is disabled). Is there any other way or rather a correct way to place the variable?

      The code:
      void mouseDoubleClickEvent(QMouseEvent* event,int key, int increment);

      where there is QMouseEvent* event AND int key and int increment.

      PS: Do let me know if i got the terms right as well.

      Thank you so much QT community :)

      JonB 1 Reply Last reply Reply Quote 0
      • JonB
        JonB @Faruq last edited by

        @Faruq said in mouseDoubleClickEvent minor problem (pointers and variable as Argument of function):

        But it doesn't work (As if it is disabled)

        What does that mean? Did you a compilation error message?

        void mouseDoubleClickEvent(QMouseEvent* event,int key, int increment);

        As it stands, this is a a method formal definition (e.g. like you might have in a .h file). Did you intend this as a definition or a call to the method?

        1 Reply Last reply Reply Quote 0
        • F
          Faruq last edited by

          Hi thank you for your reply. It's doesn't show any error log. However I know there is something wrong as It didn't work out how I want it to be. For an instance, double clicking would result the dialog to close. But it doesn't.

          Thus for your 2nd qn, I believe I'm using this void function to call since it's not in the header file. Is it possible for arguments to be as such? Or must the argument be of one kind?

          E. G.
          Void ( int lala, int lala) //there must be a variable type only as agument?

          Void ( pointer *point, int lala) // can this be done too?

          Ps: I think this is c++ basic but would be nice to revise/learn along the way as I go througj QT. :)

          1 Reply Last reply Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion last edited by

            Hi
            Its a virtual function and you cannot just add extra
            parameters to it as its then no longer the same function and it wont be called by Qt.
            http://doc.qt.io/qt-5/qwidget.html#mouseDoubleClickEvent
            it must be that signature. ( signature = same parameters and name)

            You can always use the override (in .h) to be told if u break a virtual function

            class AbstractNotificationbarWidget : public QFrame {
              Q_OBJECT
            public:
              explicit AbstractNotificationbarWidget(QWidget* parent = 0 );
            protected:
              void mouseDoubleClickEvent(QMouseEvent* event, int t) override  {} <<< notice the override
            public slots:
            };
            
            
            F 1 Reply Last reply Reply Quote 3
            • F
              Faruq @mrjj last edited by

              @mrjj noted! I will work on it. Thank you so much :)

              mrjj 1 Reply Last reply Reply Quote 0
              • mrjj
                mrjj Lifetime Qt Champion @Faruq last edited by mrjj

                @Faruq
                ok :)
                What you could do is to add a new signal with the extra info yo uwant.
                Then in mouseDoubleClickEvent emit that signal and the outside world could use that instead.

                1 Reply Last reply Reply Quote 1
                • First post
                  Last post