qtcore

Qt: *.pro vs *.pri

假如想象 提交于 2019-12-17 10:33:26
问题 What is the difference between *.pro and *.pri configuration files for qmake? What should go into a *.pro file and what should go into a *.pri file? 回答1: A .pro file is what you would run QMake on. A .pri file is included by a .pro file. Other than that there is not much of a difference between the two. Example usage could be if you have different builds which need different options. You could put shared information in the .pro, while deferring the options to various .pri files. A bit more

Qt: *.pro vs *.pri

你离开我真会死。 提交于 2019-12-17 10:33:23
问题 What is the difference between *.pro and *.pri configuration files for qmake? What should go into a *.pro file and what should go into a *.pri file? 回答1: A .pro file is what you would run QMake on. A .pri file is included by a .pro file. Other than that there is not much of a difference between the two. Example usage could be if you have different builds which need different options. You could put shared information in the .pro, while deferring the options to various .pri files. A bit more

Ncurses and Qt Interoperability

谁说我不能喝 提交于 2019-12-17 06:16:12
问题 Having a Qt and ncurses based application, what is the best way to refresh the screen every second, while waiting for user input? (e.g. show the clock and get user input). I need the best compromise between CPU usage and application responsiveness. To be more specific with the question, how to get user input and still use QTimer and the signal-slot mechanism? When using the code below, the timers doen't work. nodelay(stdscr,true); while(1) { sleep(1); getch(); processInput(); } 回答1: Use

Why does qjsonvalue todouble conversion cause data loss?

北战南征 提交于 2019-12-14 00:40:52
问题 QJsonValue toDouble() conversion generates wrong values causing data loss. QJsonObject obj; obj.insert("dbl",double(73183493944884961)); double d = obj.value("dbl").toDouble(); qulonglong ul = d; qulonglong ul2 = 73183493944884961; qDebug () << ul << ul2; Output: 73183493944884960 73183493944884961 回答1: toDouble() means it returns a double (that you cast to qulonglong then) which is inherently a precision loss. You can easily figure this out without involving json into this, by printing out

QCoreApplication ignores quit signal and hangs

流过昼夜 提交于 2019-12-13 16:23:23
问题 When the signal QCoreApplication::quit() is triggered synchronously before the event loop is started, the signal is ignored and the application hang forever. However, is triggered from QTimer, the application quits correctly. What would be the proper way to start a task that can return immediately before the exec loop is started? Here is a minimal code to reproduce this behavior: hang.h #ifndef HANG_H #define HANG_H #include <QObject> class hang : public QObject { Q_OBJECT public: explicit

How to access the GUI output?

泄露秘密 提交于 2019-12-13 10:32:06
问题 I'm developing one test bench which runs multiple tests via python gui and prints the output as below. A Passed B Passed C Passed D Passed E Passed Button from gui should be changed to 'Passed' only when A,B,C,D,E all are Passed. If any of these tests fails, it should say failed. What is the way to access this output from gui which is printed on screen. My code for tests is: from PyQt4.QtCore import * from PyQt4.QtGui import * import sys, os, time from PyQt4 import QtGui, QtCore from progress

Getting paths of qrc files in Qt

浪子不回头ぞ 提交于 2019-12-12 12:25:39
问题 I want to know how to access the paths of files in the qrc file in order to use them as strings in an array. An example of qrc file is: <!DOCTYPE RCC><RCC version="1.0"> <qresource prefix=""> <file>images/1.jpg</file> <file>images/2.jpg</file> <file>images/3.jpg</file> <file>images/4.jpg</file> </qresource> </RCC> I want to use it in the following manner: for(int i=0;i<4;i++) { path=image_path[i]; } where path is an qlist that can be later used for accessing the respective images. 回答1: There

How to detect Windows shutdown or logoff in Qt

人盡茶涼 提交于 2019-12-12 08:49:39
问题 I am porting a Linux app to Windows written in Qt. The application needs to save some settings before closing. On Linux, we can do that by signal handlers for SIGTERM etc. How can I implement the same on Windows. 回答1: If you are using the Qt event loop, you can catch the following signal: void QCoreApplication::aboutToQuit() [signal] This signal is emitted when the application is about to quit the main event loop, e.g. when the event loop level drops to zero. This may happen either after a

QThread weird behaviour [closed]

隐身守侯 提交于 2019-12-12 02:53:40
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I have a QThread running some code and I wanted it to do exit nicely and do some cleanings so the code goes as: testdevice.h class testDevice : public QThread { Q_OBJECT ... // some definitions protected: void run(void); private: hid_device *handle; bool abort; public: ~testDevice(void); }; testdevice.cpp

QThread Slots behavior

↘锁芯ラ 提交于 2019-12-11 18:06:54
问题 I am new to C++ and Qt and I am wondering what happens if I emit a signal in object1 running in thread1 , to another object2 running in another thread2 and object2 is running an infinite loop for processing? Will the slot in object2 never be called since the thread2 is busy running the loop? 回答1: I am new to C++ and Qt and I am wondering what happens if I emit a signal in object1 running in thread1, to another object2 running in another thread2 and object2 is running an infinite loop for