mouseDoubleClickEvent minor problem (pointers and variable as Argument of function)
-
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 :)
-
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 :)
@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? -
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. :)
-
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: };
-
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: };