[Interest] qApp desktop weirdness

Sensei senseiwa at gmail.com
Fri Mar 1 15:10:30 CET 2013


Dear all,

I am looking through this for quite some hours, I turn to you to let me 
see my error... it seems I can't spot that... I'm probably tired.

I have a very easy class hSettings that must store the window size, and 
to init that, I use

         QRect desktop = qApp->desktop()->geometry();

Of course, the header includes <QtCore>, and I get an error:

/Users/sensei/Documents/Projects/htools/hTools/hTools/hSettings.cpp:23:31: 
error: no member named 'desktop' in 'QCoreApplication'
         QRect desktop = qApp->desktop()->geometry();
                         ~~~~  ^


I am puzzled, because I copied the code from another (perfectly running) 
application.

So, I went to the main window class, and add this to the destructor:


hMainWindow::~hMainWindow()
{
     qWarning("width is %d", qApp->desktop()->geometry().width());
}


And behold! It compiles! qApp for an unknown reason now has desktop()...


If you want to take a look at the source code, it's here:

https://bitbucket.org/senseiwa/htools/src




If anyone can help me dispel this curse, I'd really appreciate it: I 
know it must be an utterly stupid error!


Thanks & Cheers!












More information about the Interest mailing list