1

Hi I'm writing multilanguage application in Qt5. I want to access

QApplication a(argc, argv);

localised in main.cpp from my Settings class. I need this to perform 2 commands:

a.installTranslator();
a.removeTranslattor();

when I'm trying to do do this I'm getting errors:

C2228: left of '.installTranslator' must have class/struct/union
C2228: left of '.removeTranslator' must have class/struct/union

How can I call it?

km2442
  • 779
  • 2
  • 11
  • 31

1 Answers1

3

Depending on the function you need, you have two options:

  1. QApplication has several static methods, so you can call them from almost everywhere as long as you include the header.
  2. As you already comment, there is a global pointer qApp allowing further access to non static methods. This is becase a QApplication is a singleton in any Qt App.

Note, this is valid for Qt 4 and Qt 5.

Ariel M.
  • 896
  • 8
  • 24