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

Pyqt5 window full screen does not show border

I create a pyqt window without any title bar and transparent. Also added blue border for my window but when on running the app I can't see any blue border for the window. from PyQt5.QtWidgets import * from PyQt5.QtGui import * from PyQt5.QtCore…
Himanshu Poddar
  • 7,112
  • 10
  • 47
  • 93
0
votes
1 answer

QObject Child Class Not Detecting QGuiApplication Event Loop

When I try to start a QTimer in a class derived from QObject, I get the warning QObject::startTimer: Timers can only be used with threads started with QThread and the timer doesn't run. Based on answer here, it appears that my custom class is not…
0
votes
1 answer

QEventLoop in QAxWidget instance failed

I'm working on terminal based PyQt application using Windows OCX api. And I'm having trouble over implement(calling exec) QEventLoop in QAxWidget instance. If I call exec() in main QApplication main loop, everthing is fine. But, calling exec() in…
DWONH
  • 1
  • 3
0
votes
1 answer

Connecting button to create and store an object in Qt C++

I am creating a Qt Widget based app and I want to be able to add objects to std::list<>(that store objects of some class) at runtime by using button(QPushButton). Is there any way to pass this list by reference so I can store created objects in…
0
votes
1 answer

PyQt5 Widget Disappears When No Breakpoint is Used

Don't critisize me using different classes - the reasons for his is becausethere will be more GUIs in my project created by the QtDesigner, but this should not be important for now. In general, I have two Python scripts: main.py: from PyQt5 import…
0
votes
1 answer

How to have a timer in main.cpp in qt creator to update the GUI when a button is clicked?

I am creating a laundry machine simulation with my team for school. I have simulation.cpp where I have functions to control the GUI and main.cpp where I only call one Work() function which is supposed to check whether the user has clicked on a…
Eda
  • 93
  • 9
0
votes
0 answers

How to properly open a 12-bit tiff file to use in a QApplication

Context: I am creating an application to view a stream of images using PyQt5. I am opening either jpg images or 12-bit tiff images, depending on the folder chosen. These images are converted into numpy arrays, and then into QImages and QPixmaps. So…
MochaPower19
  • 3
  • 1
  • 3
0
votes
1 answer

How to jump from 1 qt window to other in pyqt5.?

I am working on pyqt5 project where I have login window and registration window. I have a button on login window which when clicked should open the registration window. I have designed the ui in qt desginer and have converted the .ui files to .py…
S Andrew
  • 5,592
  • 27
  • 115
  • 237
0
votes
0 answers

QTimer reset to 60 seconds every time user interacts with GUI after 5 seconds of inactivity

I built a small GUI that has shutdown feature after 1 minute. There is a count down that the user can see. The GUI could be left open and inactive if the user does not interact with it of course. The problem I have is that I am trying to reset the…
Emanuele
  • 2,194
  • 6
  • 32
  • 71
0
votes
1 answer

Set X Y Coordinates in QGraphicsItem QT

To determine the coordinates of an object with Qapplication and QGraphicsItem Library,Usually used setPos and setPos(mapToParent(yvelocity,-xvelocity)).The problem with these commands is that they determine the "speed" of the object move(Not their X…
esmaeil
  • 1
  • 2
0
votes
0 answers

QT Qapplication stuck in "return a.exec() " in calculation Loop

I simulated a dynamical device like mass spring damper.the QT Solves the equation of motion in Real Time and displays the output. I want to use an Qapplication object,to display Data and the outputs in "Real time". whole problem and display output…
esmaeil
  • 1
  • 2
0
votes
1 answer

in QT in field of Signals & Slots, What signal should I put in the connect command when i solving the dynamic equation in "Real time"؟

I simulated a dynamical device like mass spring damper.the QT Solves the equation of motion in Real Time and displays the output. I want to use an Qapplication object,to display Data and the outputs in "Real time". I don't know What should I put the…
esmaeil
  • 1
  • 2
0
votes
0 answers

qt QApplication doesn't Display Realtime data

I have two separate c++ projects that run simultaneously and exchange information between them using TCP/IP. The names of those two projects are "World" and "Platform". To display Data and output in Real time, I have created a Qapplication object…
esmaeil
  • 1
  • 2
0
votes
0 answers

QApplication setFont() and QTimer

When I setup font for Qt application, it has no effect on the part of code executed on QTimer's timeout() signal. main.cpp #include "mainwindow.h" #include #include #include int main(int argc, char…
swapfs
  • 1
  • 2
0
votes
0 answers

How to run different QApplication instances in different threads

I've a Qt application, that must be able to load plugins. When the plugin is loaded (I use boost::dll) I call the plugin factory method for retrieving a class with the followed (simplified) interface: #ifdef _WIN32 using WindowHandle =…
Jepessen
  • 11,744
  • 14
  • 82
  • 149