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. mouseDoubleClickEvent minor problem (pointers and variable as Argument of function)
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 741 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.
  • F Offline
    F Offline
    Faruq
    wrote on last edited by
    #1

    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 :)

    JonBJ 1 Reply Last reply
    0
    • F Faruq

      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 :)

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

      @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
      0
      • F Offline
        F Offline
        Faruq
        wrote on last edited by
        #3

        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
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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
          3
          • mrjjM mrjj

            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 Offline
            F Offline
            Faruq
            wrote on last edited by
            #5

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

            mrjjM 1 Reply Last reply
            0
            • F Faruq

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

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

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

              • Login

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