12/22/2023 0 Comments Qt creator signals and slotsThe previous example shows one way that works across old versions of Qt published so far (Qt 1 to 5). The new versus the old way to use connect So signals and slots are very safe by default, and in an automatic way. ![]() But for the sender to call the receiver, it needs a pointer to it, and you as a user, don’t need to worry at all about the receiver being destroyed and becoming invalid (that is done automatically by the library), so you very rarely need to call QObject::disconnect. If the sender object is destroyed, it obviously can not emit any signal because it is a member function of its class. This has a very subtle advantage over a typical mechanism used in standard C or C++ 11 like callbacks with function pointers and lambda functions wrapped in std::function, and is subtle only because is so nice we often forget about it when we have used signals and slots for a while. ![]() ![]() Now to the main point that I want you to notice here. That could be a typical statement from a “Hello World” tutorial, where a button is created and shown, and when it’s pressed the whole window closes and the application terminates.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |