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
0 answers

QApplication freeze sometimes, if i import QWebEngineView

from PyQt6.QtWidgets import QApplication from PyQt6.QtWebEngineWidgets import QWebEngineView import sys print("0") app = QApplication(sys.argv) print("1") if i remove that line from PyQt6.QtWebEngineWidgets import QWebEngineView there is no…
Omer ANAR
  • 1
  • 5
0
votes
0 answers

How to include QML Oscilloscope example

I am trying to use this source to create an oscilloscope view on my application. Here is the source i am using which is created by QT team https://code.qt.io/cgit/qt/qtcharts.git/tree/examples/charts/qmloscilloscope?h=6.2 I have a lot of screens but…
utkuyceng
  • 43
  • 6
0
votes
0 answers

How to check filtered item in checkable ComboBox?

If an item in the list is selected using a filter, it becomes non-checkable. For filter I use functions: on_completer_activated, setModel, setModelColumn. I added a filter model to filter matching items (QSortFilterProxyModel), added a completer,…
0
votes
1 answer

Pushing QWidget Window to topmost in Python

I'm new to Python and have mostly learnt C# in the past. I am creating a QWidget class: class Window(QWidget): def __init__(self, gif, width, height): super().__init__() self.setGeometry(400, 200, width, height) …
0
votes
0 answers

Cannot Close Spyder with PyQt5

I need your help! I built a GUI with PyQt5 and my IDE is Spyder! When I run PyQt in Spyder I cannot close it. What's the problem? Also when I run it a second time, the menubar disappears... import sys from PyQt5 import QtWidgets from PyQt5.QtWidgets…
chilli93
  • 63
  • 4
0
votes
0 answers

QT5 Application Screen not refreshing after resolution change through Linux framebuffer

Having issue at runtime after changing framebuffer resolution, I have Qt 5.14.2 running on top of linuxfb platform plugin. My QApplication come up in 1024X768 resolution, then change to 1280x1024 resolution using ioctl call to fbdev. The resolution…
0
votes
1 answer

'NoneType' error when calling QApplication(sys.argv), pycharm

I'm new to PySide2 and I'm facing this issue while creating super simple window with PySide2 and Pycharm: Qapplication() error :'NoneType'; both with sys.argv as argument and without any argument the error occur. I'm using mayapy.exe as python…
simogerr
  • 1
  • 2
0
votes
1 answer

Qt , how to create QApplication without argc and argv

Hey so I need to export a qt application as a .dll and , so I dont want any arguments like argc and argv , but QApplication needs them , so i tried this int main() { int c=1; char** v = (char**)("ApplicationName"); QApplication…
0
votes
1 answer

QML menu style only works in QtWidgets QApplication

I am running Qt 5.11.0 under Windows (I understand that it is very old but I cannot upgrade that embedded system). For some reason, QML Menu from QtQuickControls1 ignores its style if app is a QGuiApplication, but works if it is a QApplication (from…
Jack White
  • 896
  • 5
  • 7
0
votes
0 answers

I get "Release of profile requested but WebEnginePage still not deleted. Expect troubles !" even after calling app.exec()

I have a python code like below import sys from PyQt5 import QtWidgets, QtWebEngineWidgets from PyQt5.QtNetwork import QNetworkCookie from PyQt5.QtCore import QUrl, QTimer from PyQt5.QtGui import QPageLayout, QPageSize from PyQt5.QtWidgets import…
AMendis
  • 1,346
  • 4
  • 18
  • 34
0
votes
2 answers

How to start a QApplication from shell without blocking it?

I have a simple Qt5 Application which can be installed as a pip package. The package has an entry point so i can start the application via a command prompt. The called function looks like the following: def start_app(): app =…
0
votes
1 answer

How to send data from one window to another window Pyqt5 using signals

I am trying to send data from my login window to admin dashboard I have three files Main App which contains QApp from PyQt5 import QtWidgets import sys, loginScreen, adminPanel from dbHandler import databaseHandler try: dbCon =…
0
votes
0 answers

Edit Qt Qapp style setting to create dark mode

Just found some awesome free (speech) software to speak to some lab equipment. The background is very white though and I would like to put it in to dark mode. I know nothing about C++. In main.ccp I found this…
dogfood
  • 3
  • 1
0
votes
0 answers

Display foreign window inside PyQt5 QMainWindow

I am using Windows 10 I am trying to display cmd to my PyQt5 Application I tried Running a Windows executable (calc.exe, etc) inside a PyQt Application But It just opens the application outside the PyQt5 application Can anyone help me? Thank you
0
votes
0 answers

QApplication initialization is very slow with mingw

I having trouble with this code, since the QApplication line takes several seconds to return: #include #include #include #include int main(int argc, char **argv) { auto t1 =…
PJ127
  • 986
  • 13
  • 23