QT: SIGNAL & SLOT macro -


i'm beginner in qt , when tried use connect method bind signal , slot , refered examples found standard usage of

connect(obj1,signal(signal(int)),obj2,slot(slot()))

however when use

connect(obj1,&obj1::signal,obj2,&obj2::slot)

it worked , question occurs me did macro signal , slot ,did signal in class object belongs , return address of it?

then why programmers use these macros instead of using &obj1::signal latter appears simpler , don't need edit code when changing parameter of signals .

thanks answering.

the use of signal , slot macros used way make connections, before qt 5. connection made @ runtime , require signal , slots marked in header. example: -

class myclass : public qobject {      q_object        signals:         void signal();      slots:         void aslotfunction(); }; 

to avoid repetition, way in works described in qt 4 documentation.

the signal , slot mechanism part of c++ extensions provided qt , make use of meta object compiler (moc).

this explains why signals , slots use moc.

the second connect method improved functions specified can checked @ time of compilation, not runtime. in addition, using address of function, can refer class function, not in section marked slots:

the documentation updated qt 5

in addition, there's blog qt 4 connect workings here , qt 5 here.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -