What signals are 1) available to any Item 2) first to be sent
-
Within the module that I am working on, in QtCreator, I pressed, Ctrl-Space. It brought up a list of available options, including the signal handlers, onDataChanged and onResourcesChanged. I cannot find any documentation on associated signals/handlers. Then again, I can't find a list anywhere of what signals are sent to an Item. I point to Item as it is the base of all the QML modules. (At least the GUI ones.) There is no list of associated signals in the documentation for Item. (Using QML 5.15.)
I need to know the earliest signal sent to an Item as I have an icon to set, along with a title string. They are formatted in the item so that the icon is on the left side of the string in a RowLayout. (Yes, I like layouts far more than anchors.) Based on a couple of booleans and some stretch items I created, I can align the icon and text left, centered or right. But I noticed that the icon and text were not coming up as set in onVisibleChanged, so I need an earlier signal. (Second showing of the module did show correctly. Sort of a custom dialog. No, I can't use Dialog. System issue.) A signal sent as early as possible would be best.
Thanks.
-
@VFCraig said in What signals are 1) available to any Item 2) first to be sent:
Within the module that I am working on, in QtCreator, I pressed, Ctrl-Space. It brought up a list of available options, including the signal handlers, onDataChanged and onResourcesChanged. I cannot find any documentation on associated signals/handlers.
That would be https://doc.qt.io/qt-5/qml-qtquick-item.html#data-prop and https://doc.qt.io/qt-5/qml-qtquick-item.html#resources-prop
Then again, I can't find a list anywhere of what signals are sent to an Item.
That depends on the code you write. It cannot be documented in advance in Qt documentation.
I point to Item as it is the base of all the QML modules. (At least the GUI ones.) There is no list of associated signals in the documentation for Item. (Using QML 5.15.)
Every property you see equals a signal with the same name +
Changed()
.Plus, of course, all signals from parent classes: https://doc.qt.io/qt-5/qobject.html and https://doc.qt.io/qt-5/qquickitem.html
I need to know the earliest signal sent to an Item as I have an icon to set, along with a title string.
No signal is sent to an Item unless you send it or set up a property binding. And since QML is declarative, any order of signals is not guaranteed to be kept.
They are formatted in the item so that the icon is on the left side of the string in a RowLayout. (Yes, I like layouts far more than anchors.) Based on a couple of booleans and some stretch items I created, I can align the icon and text left, centered or right. But I noticed that the icon and text were not coming up as set in onVisibleChanged, so I need an earlier signal. (Second showing of the module did show correctly. Sort of a custom dialog. No, I can't use Dialog. System issue.) A signal sent as early as possible would be best.
You may be looking for:
Component.onCompleted: { // blah blah blah }
But from all you wrote so far, it looks like you approach the problem in a wrong way. In QML, you declare how you want your UI to look, and QML engine does that. You don't explicitly tell it when to do stuff. Order of execution does not matter at all and is not defined.
Maybe you can share some of the code, write how it fails and how you expect it to work, and we'll be able to help you better.
-
Ideally I am looking for something before onCompleted so I can set items to draw it as intended.
Yes, I know that every property generates an associated signal (no matter what I think of the, "on", approach to doing so.
But Item is the basis for every GUI module. Therefore, every child of Item should have at least the same signals associated with it as Item. On the C++ side of the documentation, listing all inherited properties would include inherited signals as well. Item has an onVisibleChanged signal, but there is no listing of it in Item's documentation. (Or at least that use to be the case, but the documentation appears to have fallen off quite a bit over the years. Trolltech had tremendous docs for their releases.)
-
@VFCraig said in What signals are 1) available to any Item 2) first to be sent:
Ideally I am looking for something before onCompleted so I can set items to draw it as intended.
Yes, I know that every property generates an associated signal (no matter what I think of the, "on", approach to doing so.
But Item is the basis for every GUI module. Therefore, every child of Item should have at least the same signals associated with it as Item. On the C++ side of the documentation, listing all inherited properties would include inherited signals as well. Item has an onVisibleChanged signal, but there is no listing of it in Item's documentation. (Or at least that use to be the case, but the documentation appears to have fallen off quite a bit over the years. Trolltech had tremendous docs for their releases.)
The signal is
visibleChanged()
. There is noonVisibleChanged
slot - it is only created when you declare it. Yes, signals are not explicitly listed, it's "you have to know it" stuff. Feel free to suggest a change inqdoc
on Qt bugtracker, I imagine this could be quite easy to add.I still don't understand why you need to get such an early and strict access to an item when it is being created. But perhaps it would help you to dive into the C++ side and reimplement
componentComplete()
https://doc.qt.io/qt-5/qqmlparserstatus.html#componentComplete or inject custom painting inupdatePaintNode()
https://doc.qt.io/qt-5/qquickitem.html#updatePaintNode.