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 problem: When I quit the main QApplication by closing its QMainWindow, the QMainWindows in the subprocess are closed without receiving a closeEvent, and consequently do not store their position and size.
The question: What is the solution ?
Thanks
Related
I am planning a Qt simulator, i.e. a GUI surface in one thread receives the signals
emitted from another thread (this other thread is suspended -not resumed- while processing),
while the main program is essentially just for starting the two threads.
I found
How to emit cross-thread signal in Qt?
which works (after adding a missing semicolon), but after calling
MyObject::MySlot (i.e. printing the text ""slot called"), the control goes to
CThread2::exec() and is not given back CThread1::run(), which would emit further signals.
It looks like its event loop keeps waiting for another event.
I do not want either thread to quit: CThread1 is expected to emit a series of signals,
and CThread2 is expected to process them.
What is wrong here? (the MWE is provided in the reply part of the thread above)
Another question, how a GUI surface can be moved to a thread, given that
http://doc.trolltech.com/4.6/qthread.html
states that
"Note, however, that it is not possible to use any widget classes in the thread."
I'm Trying to create an AreaChart Using ChartView over a QApplication on Raspberry Pi But no matter how small or big the chart is, QApplication Increase Start Time of my App to Over 20 sec and after that about 5-10 sec to show chart.
is there any alternaive to ChartView to use on QML that use faster QT based Object(QGuiApplication,etc) ??
or is there any method to increase run time of QApplication (Beside what they said in This)
QT Version = 5.11.3
any help would appreciated.
I'm building a real-time system in Qt. Every 20 ms I need to paint 5 points in a QFrame to make the painting of a signal looks like real time. When I only paint the signal in the QFrame, the call to paintEvent() is done with the desired frequency, 20 ms. But when I focus on another QWidget or when I show another window (in other words, when I perform another painting action that isn’t very simple) the call to paintEvent() starts to slow down and the samples of the signal are accumulated.
The call to the function paintEvent() is made from the call to the function update() of the QFrame every 20 ms. In Qt you cannot separate the painted gui into threads. Therefore, the call to paintEvent() runs in the same thread as the call to the functions responsible for the other actions of painting in the gui. This causes that when focusing another QWidget, when the processing associated with painting a box in the QWidget is delayed, the event of painting the signal is delayed.
The question is whether there is any way to make the event to paint signal priority, so that paintEvent() is called with the same frequency, no matter what it is done in the gui. I use repaint instead of update, because in the help of Qt it says that repaint makes the direct call to paintEvent(), but the result was disastrous.
Any other idea will be of great help.
Silly question, but can I know at the time of the window's "CloseEvent" event if the window is being closed because it received a cmd-q keystroke, or a cmd-w keystroke?
If you need to understand how an user has closed your application you can install filter on QApplication and check every keystrokes here. If you encounter one of those you can do something: log it, send signal, set global flag etc. With global flag you can know for sure in close event if some keystroke has been used.
if the maximum wait time is 10 ms can i use qwaitcondition in Qt's main thread?
Nothing stops you from using QWaitCondition in the main thread. If you are setting the wait time to 10ms, and it passes without unlocking you will probably not get the desired effects you want. The default is to wait indefinitely.
However, using a wait condition in the main thread will cause the GUI to become unresponsive while it waits. This is almost always undesired.