installSignalHandler
installSignalHandler(objectOrName, signalSignature, handlerFunctionName)
This function installs a Qt (not Unix!) signal handler that eavesdrops on the specified objectOrName
widget. The signalSignature
must be the exact signature used in C++ with no parameter names—for example, "activated(int)"
or "triggered(QAction*)"
. The handlerFunctionName
(which must be passed as a string, not as a function reference), will be called whenever the specified widget emits the specified signal and will be passed a reference to the object that emitted the signal, followed by all the signal's arguments (if there are any).
Note: When defining signal handlers of QML signals, the argument types still must be the C++ types. In particular, this means that for a real
QML argument, you must use the C++ double
type, and for a string
QML type, you must use QString
.
As is usual with Squish functions, the objectOrName
widget must exist at the time this function is called. This requirement is relaxed by the installLazySignalHandler(name, signalSignature, handlerFunctionName) function which can only accept a symbolic or real name, but of an object that need not exist when the function is called. Nonetheless, it is best to use this installSignalHandler
function whenever possible since it is potentially a lot faster than the installLazySignalHandler(name, signalSignature, handlerFunctionName) function.
Where possible the signal's arguments are passed as types that can be handled normally such as numbers, strings, or their actual Qt types such as QAction
or QTableWidgetItem
. However, some types are sent as plain Squish Object
s; custom types and other unrecognized types are passed as strings.
For an example, see How to Use Qt Signal Handlers.
© 2024 The Qt Company Ltd.
Documentation contributions included herein are the copyrights of
their respective owners.
The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners.