[Qt-interest] static struct of QIcons?
Kārlis Repsons
k at 11.lv
Mon Mar 29 22:21:02 CEST 2010
On Monday 29 March 2010 18:59:32 K. Frank wrote:
> To All -
>
> I have a suggestion -- that doesn't seem to work -- and a question.
...
> static MyIcons icons;
...
> Would anyone know what is going on here?
Well what is going on, when you declare that struct as static is that it's
tried to be initialised immediately upon the start of application, but there
are some Qt things, which need to be done beforehand. So you can't make it
static. Nevertheless, there is nothing really there to loose -- things are
well with a struct for a class with a single instance. Like this for me:
in class decl.:
-------------------------------------------------
const struct Icons
{
QIcon minus;
QIcon plus;
QIcon exit;
Icons();
} icons;
-------------------------------------------------
in cpp:
-------------------------------------------------
MainWindow::Icons::Icons():
minus(":/images/minus.png"),
plus(":/images/plus.png"),
exit(":/images/exit.png")
{
}
-------------------------------------------------
And it seems to be what I need, at least works this far.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100329/0d670e71/attachment.bin
More information about the Qt-interest-old
mailing list