Seite 1 von 1

[gelöst] Auf qApp zugreifen

Verfasst: 30. Dezember 2006 18:12
von grosem
Hi,

in der Dokumentation steht The global qApp pointer refers to this application object.

Ich hatte das so interpretiert, dass ich ÜBERALL auf qApp zugreifen kann (btw.: was sind globale Pointer, wusste gar nicht, dass es sowas gibt...), was aber anscheinend nicht der Fall ist:

Code: Alles auswählen

error: 'qApp was not declared in this scope

Verfasst: 30. Dezember 2006 18:41
von franzf
Such mal im Assistant nach qApp, dann findest du das hier:

Code: Alles auswählen

qApp
A global pointer referring to the unique application object. It is equivalent to the pointer returned by the QCoreApplication::instance() function.
Only one application object can be created.
See also QCoreApplication::instance()
Somit solltest du erfolgreich sein, wenn du QCoreApplication includest.

Wenn du in deiner main-Schleife eine QApplication verwendest, geht das natürlich auch.

Grüße
Franz

Verfasst: 30. Dezember 2006 18:47
von grosem
franzf hat geschrieben:Such mal im Assistant nach qApp, dann findest du das hier:

Code: Alles auswählen

qApp
A global pointer referring to the unique application object. It is equivalent to the pointer returned by the QCoreApplication::instance() function.
Only one application object can be created.
See also QCoreApplication::instance()
Somit solltest du erfolgreich sein, wenn du QCoreApplication includest.

Wenn du in deiner main-Schleife eine QApplication verwendest, geht das natürlich auch.

Grüße
Franz
Wenn ich

Code: Alles auswählen

#include <QApplication>
mache, dann kann ich auch auf qApp zugreifen. (Ansonsten "nur" über die von dir erwähnte instance() Funktion). War mir nicht klar, dass ich das muss, aber im Nachhinein ist es ja logisch...

Danke :D