[Bug?] Object name set in Qt Designer isn't set on promoted widget.
-
Hello,
Is this a bug? I name my promoted widgets, but their objectNames are empty at run-time.
-
Anyone? I just want to know what to expect, since I'm new to Qt and I have no clue if promoted widgets are supposed to get their Qt Designer names...
-
Hi,
That does sound like a bug indeed. Would you be willing to file a bug report at https://bugreports.qt-project.org ?
-
-Yep, thats exactly why I asked ^_^-
Welp, it seems the name isn't set in the constructor... When thinking about how to fix this, a signal magically appeared... It was calling for my attention, quietly sitting in its little window. I glanced and, ironically, to my surprise, it was called ObjectNameChanged(QString)...
As such, I went back to coding, enlightened and left completely abash... "Someone may have all ready encountered the exact same issue I currently have", I thought to myself, gazing lightly at my screen.
I then proceeded to code a little example output, pressed cmd+r, and the universe suddenly woke up. "This would be to easy!", said the universe. "Nobody gets to work quickly when coding". At that instant, the universe decided that the signal would not be called when the object name is set for the first time. I turned and bowed my head, in despair, back to where I was before, looking for a solution to my problem.
Something along those lines ;)
-
Great story :-D
Anyway, I found out that setupUi() is the function that sets the object names. Make sure you call that before doing anything else in your constructor.
Note: The signal is emitted in the constructor. The thing is... the slot hasn't been connected yet! That's why you don't receive the first signal.
-
ah! Thank you very much for the clarification. I guess I can quickly fix it by iterating over my custom widgets and calling ObjectNameChanged() myself after setupUi. A bit "bruteforcish", but will work for now.
I'll be back with more "stories from the trenches" lol