[gelöst] Auf qApp zugreifen

Alles rund um die Programmierung mit Qt
Antworten
grosem
Beiträge: 17
Registriert: 4. Juni 2006 15:52

[gelöst] Auf qApp zugreifen

Beitrag 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
Zuletzt geändert von grosem am 30. Dezember 2006 18:48, insgesamt 1-mal geändert.
franzf
Beiträge: 3114
Registriert: 31. Mai 2006 11:15

Beitrag 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
grosem
Beiträge: 17
Registriert: 4. Juni 2006 15:52

Beitrag 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
Antworten