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
0
votes
1 answer

Showing a messagebox from library

I need to show a messagebox to user from my static library but using QMessageBox needs QApplication; How can I show a message box without QApplication?
Ariyan
  • 14,760
  • 31
  • 112
  • 175
0
votes
0 answers

No closeEvent received by QMainWindows in the QApplication of a subprocess

I have a main QApplication (with a single QMainWindow) which starts a sub-process running another QApplication with several QMainWindows. These QMainWindows save their position and size when closed, as I defined in the closeEvent() method. The…
user3650925
  • 173
  • 1
  • 10
0
votes
1 answer

Creating a new Qapplication from Qapplication event loop

I have rewritten the question so that it is more clear. In my code I created a QApplication, connected a slot to the application using QTimer.singleShot(), then executed my application. Now in this slot I want to create another QApplication in…
0
votes
2 answers

(UPDATE) QT QML 5.6 - What causes this warning "QApplication was not created in the main() thread"?

[UPDATE] OK, I am updating my previous question. At first I thought the warning pops up when I remove widgets from the .pro file - which would have been peculiar behavior. After digging down, I ended up with a completely empty application and the…
spikeyeddy
  • 11
  • 4
0
votes
0 answers

QThread: "Destroyed while thread is still running" in a single threaded program

int main(int argc, char** argv) { QApplicaiton app(argc, argv); // parsing other arguments of argc,argv return app.exec(); } My problem is the following: Function may be returned during parsing other arguments (without reaching…
Ashot
  • 10,807
  • 14
  • 66
  • 117
0
votes
2 answers

How to receive event whenever a QWidget is added to QApplication's widget tree?

I want to inspect something application wide. Specifically I'd like to inspect every widget that is added to the application. Similar thing can be done in JavaScript/HTML, where you can add DOM mutation listener which fires on DOM changes. Can I…
Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778
0
votes
1 answer

Show fullscreen webpage in 5 seconds then close window (python)

I want to make a python script that opens up a local html file in browser and after 5 seconds close that window. I've tried the self.close() method and if I add "time.sleep()" it will only delay the display of the web content Here's my code (I'm a…
Stichy
  • 1,497
  • 3
  • 16
  • 27
0
votes
0 answers

PySide QApplication breaks datetime.strptime() month recognition

I am using datetime.strptime() to get the month number from a month, written in full english. I want to use this in combination with some PySide Qt intetrface. However, the month recognition seems to break as soon as I start a QApplication. Minimum…
Arvest
  • 13
  • 1
  • 5
0
votes
0 answers

Send input events to second applications

I've a qt 5.5 application working on one part of a monitor displaying it's user interface. A different application does this for the rest of the screen. My question is: does a practical solution exists to display a transparent widget above the…
Hhut
  • 1,128
  • 1
  • 12
  • 24
0
votes
1 answer

Qt QGraphicsView application is always using 15% CPU.

I have a Qt application that is built around a QGraphicsView/Scene. The graphical performance is fine, animations are extremely smooth and a simple high res timer says the frames are drawing as fast as 400 fps. However, the application is always…
jasonlg3d
  • 484
  • 2
  • 7
  • 18
0
votes
1 answer

How to register for ACTION_VIEW Intent on Android? Why doesn't my QApplication receive QEvent::FileOpen events?

I am trying to register a QtQuick Android application to open a certain class of files and handle them. From what I gather, when a file is opened with a QApplication it results in a QEvent::FileOpen being fired. The strongest (if inconclusive)…
Tobia Tesan
  • 1,938
  • 17
  • 29
0
votes
1 answer

Qt creator vs 2013 (error c1057)

iam trying to build this program but it give me c1057 fatal error . When i removed connect function (line 15) it worked well and i don't know the reason this is the message : C:\Users\Ahmed\Documents\Qt-App\SpinnerAndSliders\main.cpp:15:…
Ahmed Nabil
  • 41
  • 1
  • 2
  • 8
0
votes
0 answers

Errors connected with creating QMathGL class in application

I have a problem with MathGL library and creating MathGL instance in the application. Every time I try to run it there is an error saying that QApplication must be constructed before QWidget (from which the class QMathGL inherits). Below you can…
Oxide
  • 11
  • 1
  • 4
0
votes
1 answer

Should my schizophrenic console/gui Qt5 program use QApplication or QCoreApplication?

My program will either open a GUI or not depending on some commandline parameters. Right now I am instantiating QApplication for my main event loop, but noticed that my program aborts when run from a headless machine (missing xorg/xcb) unless i…
Mr. Developerdude
  • 9,118
  • 10
  • 57
  • 95
0
votes
1 answer

QApplication is lazy (or making other threads lazy in the app)

This is my first post here and I hope to find a solution to my problem. I have started developing an app for Mac using Qt. I am facing a huge and frustrating problem right now. My problem is QApplication event loop becomes lazy (or makes other…
1 2 3
10
11