[Qt-interest] Setting a label's value from a slider automatically on launch
Jason H
scorp1us at yahoo.com
Wed Aug 24 19:25:25 CEST 2011
You can always call the slot directly.
I remember there being some initialization-time problem with initializing certain things in the constructor, so I'm going to share my solution.
In your QMainWindow constructor:
{
...
QTimer::singleShot(0, this, SLOT(initialize()));
}
Where initialize() is your initialization code (a slot). This will "kick" your Gui as soon as the event loop is idle, after your constructor has completed.
Unfortunately it has been a while and I am forgetting what scenarios this special kick is needed. I am thinking it is needed when you need to run stuff through the event loop, but you have not called app.exec() yet. The timer will bridge from the constructor over to after the event loop is running.
________________________________
From: David Doria <daviddoria at gmail.com>
To:
Cc: qt-interest <qt-interest at qt.nokia.com>
Sent: Wednesday, August 24, 2011 1:03 PM
Subject: Re: [Qt-interest] Setting a label's value from a slider automatically on launch
> Remember that if slider isn't moved, no signals are fired, so you need
> to set the first value by hand.
Yea, that is definitely the issue, I was just wondering if there was
some magic way to tell everything to "fire your initialization
signals" or something like that. When you get a bunch of controls on
the form, manually setting them all seems to leave a lot of room for
error. I just wanted to check here first to make sure this is a common
issue to need to handle before continuing to do them manually.
David
_______________________________________________
Qt-interest mailing list
Qt-interest at qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110824/6248c988/attachment.html
More information about the Qt-interest-old
mailing list