开发者

public slots but not signals in qt

开发者 https://www.devze.com 2023-01-10 02:39 出处:网络
Can somebody please explain why do I create in q开发者_Go百科t public slots but not public signals?Slots are normal functions, and can be public, private or protected.

Can somebody please explain why do I create in q开发者_Go百科t public slots but not public signals?


Slots are normal functions, and can be public, private or protected.

Signals are always protected when eventually generated by the 'moc' program.

But note this (from some old Qt 4.7 docs):

Since slots are normal member functions, they follow the normal C++ rules when called directly. However, as slots, they can be invoked by any component, regardless of its access level, via a signal-slot connection. This means that a signal emitted from an instance of an arbitrary class can cause a private slot to be invoked in an instance of an unrelated class.


SLOTS are functions which can be public, private or protected.Functions are called from any where i.e with in the class or outside the class.But SIGNALSare like events and it should be emitted within the class or from the inherited class so SIGNALSare always protected.

0

精彩评论

暂无评论...
验证码 换一张
取 消