Questions tagged [qapplication]

The QApplication class is part of the Qt C++ classes manages the GUI application's control flow and main settings.

The QApplication class manages the application's control flow and main settings. QApplication specializes QGuiApplication with some functionality needed for QWidget-based applications. It handles widget specific initialization, finalization.

For any GUI application using Qt, there is precisely one QApplication object, no matter whether the application has 0, 1, 2 or more windows at any given time.

Some GUI applications provide a special batch mode ie. provide command line arguments for executing tasks without manual intervention. In such non-GUI mode, it is often sufficient to instantiate a plain QCoreApplication to avoid unnecessarily initializing resources needed for a graphical user interface.

The QApplication object is accessible through the instance() function that returns a pointer equivalent to the global qApp pointer.

QApplication's main areas of responsibility are:

  • It initializes the application with the user's desktop settings such as palette(), font() and doubleClickInterval(). It keeps track of these properties in case the user changes the desktop globally, for example through some kind of control panel.
  • It performs event handling, meaning that it receives events from the underlying window system and dispatches them to the relevant widgets. By using sendEvent() and postEvent() you can send your own events to widgets.
  • It parses common command line arguments and sets its internal state accordingly. See the constructor documentation below for more details.
  • It defines the application's look and feel, which is encapsulated in a QStyle object. This can be changed at runtime with setStyle().
  • It specifies how the application is to allocate colors. See setColorSpec() for details.
  • It provides localization of strings that are visible to the user via translate().
  • It provides some magical objects like the desktop() and the clipboard().
  • It knows about the application's windows. You can ask which widget is at a certain position using widgetAt(), get a list of topLevelWidgets() and closeAllWindows(), etc.
  • It manages the application's mouse cursor handling, see setOverrideCursor().
160 questions
3
votes
1 answer

QApplication without display

I using Qt3.3 and I'm trying to create an QApplication without display. I need to check signals from QSocket objects, and this is the reason that I need the QApplication. I'm trying to do QApplication( 0, 0 ), but I'm getting "QApplication: invalid…
Etore Marcari Jr.
  • 572
  • 2
  • 10
  • 19
2
votes
1 answer

How to run a Qt application in headless mode (without showing my GUI)

I have a QT application based on a QApplication and supposing that my application has a complex GUI (QDialog, QMainWindow...). My Application can run in two modes: with GUI in headless mode I would like to know how I can launch the application in…
Pat. ANDRIA
  • 2,330
  • 1
  • 13
  • 27
2
votes
1 answer

Accessing a common data object in a PyQt application

I have a GUI programmed in PyQt with many widgets and different windows, etc. The data for the GUI is stored in a python object. This object should be reachable from every widget in the program. Where should I put this object? Right now I have it…
Benjamin
  • 298
  • 1
  • 12
2
votes
1 answer

How can I get `/sdcard` path in android using Qt APIs

I am using a QtApp on android. My QtApp has a AndroidManifest.xml as well where I can declare android permissions that my app needs. My app is well able to save anything into the private directory of the app which is…
TheWaterProgrammer
  • 7,055
  • 12
  • 70
  • 159
2
votes
2 answers

Type Error: QApplication(List[str]): not enough arguments

Disclaimer: I am relatively new to programming, and especially new to Python. I am trying to learn to build a GUI with PyQt5 and I keep receiving the error "Type Error: QApplication(List[str]): not enough arguments" when trying to launch my…
Shay
  • 43
  • 1
  • 7
2
votes
1 answer

PyQt5 - Python | QApplication.setStyle not working

I am trying to set custom style to my PyQt5 application using the setStyle() method but it doesn't work. I am also not entirely sure about where this should be put. In my main I tried doing : if __name__ == '__main__': …
Sapnesh Naik
  • 11,011
  • 7
  • 63
  • 98
2
votes
1 answer

Creating the QApplication resizes the parent (non-Qt window) when high-dpi on a 4k monitor

Using Qt5.6.1, I am using QtWinMigrate to house a Qt widget in a parent window. When the parent app is scaled for a high-dpi monitor, the following line: pApp = new QApplication( argc, argv ); kills the scaling, resizing the parent window so that…
Roderick
  • 1,205
  • 11
  • 24
2
votes
6 answers

QVideoWidget: Video is cut off

I want to play a video in a Qt Application. This is my code so far: #include #include #include #include #include #include using namespace std; const int WIDTH = 1280; const…
Stefan
  • 418
  • 5
  • 13
2
votes
2 answers

Difference between QtGui.QApplication and QtCore.QCoreApplication

What is known about QtGui is that it is used for GUI programs to create interfaces, and QtCore is for non-GUI programs and actually works under the interface. But to get the instance of the running application, I found that we can use either QtCore…
Ahmed Gad
  • 691
  • 1
  • 7
  • 26
2
votes
0 answers

Qt QApplication framerate drop when maximizing window

We are using Qt for a visualization engine viewer, and we are having issues with the QApplication::processEvents() method. Since we needed to control the framerate (in a game loop fashion), we overrided the QApplication to define our own and our…
cmourglia
  • 2,423
  • 1
  • 17
  • 33
2
votes
2 answers

How to restart an QApplication

I need to restart my application when a button is clicked, but I'm having some problems with it. I've tried two methods: Tried this suggestion and it indeed restarts the application, but I get a Gtk_IS_INVISIBLE (widget) error for every widget, and…
Diogo Magalhães
  • 441
  • 1
  • 9
  • 19
2
votes
3 answers

Is qApp->exec() valid if using a QApplication

Is it valid to call qApp->exec() or QCoreApplication::exec() if I'm using a QApplication instance? Since it's a static function, in both cases QCoreApplication::exec() will be called. However, it appears that even if I call one of them, my…
Felix
  • 6,885
  • 1
  • 29
  • 54
2
votes
1 answer

How to use QCursor::pos() without using QApplication?

I'm writing a project in Qt Creator, and if I write QPoint cursorPos=QCursor::pos(); then cursorPos={-2147483648,-2147483648} which is obviously wrong. However, if I write QApplication *application=new QApplication(argc,argv); QPoint…
user3551745
  • 33
  • 2
  • 9
2
votes
0 answers

Key modifier error on creation of qApplication

In a Qt app, on execution of QApplication a(argc, argv);, the following error appears in the console output: Error: Key "" added to modifier map for multiple modifiers; Using Mod3, ignoring Mod5 Howerver the execution does not seem to be…
Neptilo
  • 465
  • 1
  • 5
  • 17
1
vote
1 answer

can't install katalon on ubuntu 22.04

I'm trying to install katalon studio on ubunut. But it keeps giving me the following error: sudo apt-get install openjdk-8-jre sudo update-alternatives --config java //then choose the openjdk-8-jre option I followed the following steps, but with no…
Sobri Syam
  • 81
  • 1
  • 4
1 2
3
10 11