Home > Back-end >  The connect function parameters in the form of differences in Qt
The connect function parameters in the form of differences in Qt

Time:11-05

Such as a timer Qtimer class, a class QMwidget Mwidget, widget defines an animate method, then has the following several kinds of the connect call, and test all available:
The first:

The connect (timer, timer - & gt; The timeout, Mwidget Mwidget - & gt; The animate);
The second:

The connect (timer, & amp; QTimer: : timeout, widgets, & amp; QMwidget: : the animate);
The third:

The connect (timer, QTimer: : timeout, widgets, QMwidget: : the animate);
I think the first and the third is better understood, the connect of the prototype is

The connect (sender QObject * and const char * signal, QObject * receiver, const char * method);
I understand it is because the object does not save the class function code, therefore calls the timer - & gt; The timeout and Mwidget - & gt; Animate are called Qtimer class and QMwidget class methods, namely Qtimer: : timeout and QMwidget: : the animate,
But the second and the third is a bit not understand, in front of the class methods added & amp; Because QMwidget: : the animate itself says the function name, also is the function pointer, and parameter types, but add & amp; Should be the address of a function pointer, but also can use, is this why?

CodePudding user response:

There are two kinds of function Pointers, said add don't add & amp; Symbols to see to the compiler.
  • Related