qtcore

How do you serialize a QMap?

老子叫甜甜 提交于 2019-12-06 09:31:42
I'm trying to learn how to serialize QMap objects in windowed applications, using this code: #include "mainwindow.h" #include "ui_mainwindow.h" #include <QFile> #include <QString> #include <QDataStream> #include <QMap> #include <QDebug> void write () { QString filename = "Z:/snippets.txt"; QFile myFile (filename); if (!myFile.open(QIODevice::WriteOnly)) { qDebug() << "Could not write " << filename; return; } QMap<QString,QString> map; map.insert("one","this is 1"); map.insert("two","this is 2"); map.insert("three","this is 3"); QDataStream out (&myFile); out.setVersion(QDataStream::Qt_5_3);

The sip module implements API v11.0 to v11.2 but the PyQt5.QtCore module requires API v11.3

那年仲夏 提交于 2019-12-06 07:50:15
问题 I have a problem with this error. For the record, I'm using PyQt4. Thanks for any help! (C:\Users\ewasn\Anaconda2) C:\Users\ewasn\Desktop\DataShift>python data_inconsistency_api.py Traceback (most recent call last): File "data_inconsistency_api.py", line 9, in <module> from multivariate_outliers import MultivariateOutliers File "C:\Users\ewasn\Desktop\DataShift\multivariate_outliers.py", line 8, in <module> import matplotlib.pyplot as plt File "C:\Users\ewasn\Anaconda2\lib\site-packages

Can i read from .ini file which located in resources files?

走远了吗. 提交于 2019-12-05 13:45:37
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QSettings> #include <QDebug> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QSettings * qsettings = new QSettings(":/config.ini",QSettings::IniFormat); bool status = qsettings->value("preview","").toBool(); qDebug() << status; } MainWindow::~MainWindow() { delete ui; } Once i could do it but now i don't know whats wrong. When i googled this problem i just saw that this impossible but i enshure that i did it before. This works like a charm for me: main.qrc <!DOCTYPE RCC><RCC

How to use QCommandLineParser for arguments with multiple params?

久未见 提交于 2019-12-05 04:46:40
I wonder, how can I use multiple- or sub-arguments with QCommandLineParser ? For example: /home/my_app --my_option_with_two_params first_param second_param --my-option-with-one-param param? Try this which has the analogy of -I /my/include/path1 -I /my/include/path2 : --my_option_with_two_params first_param --my_option_with_two_params second_param ... and then you can use this method to have access to the values: QStringList QCommandLineParser::values(const QString & optionName) const Returns a list of option values found for the given option name optionName, or an empty list if not found. The

How to find Version of Qt?

泄露秘密 提交于 2019-12-04 08:54:09
问题 How do I know which version of Qt I am using? When I open Qt Creator it shows "Welcome to Qt Creator 2.3". In the build setting, however, it shows Qt Version 4.7.1. 回答1: qmake-qt5 --version or qmake --version 回答2: Starting with Qt 5.3 you can use: qtdiag This prints a bunch of useful information. The first line includes the version: Qt 5.5.1 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 5.3.1 20160407) on "xcb" 回答3: All the version info is in PyQt5.Qt: import inspect from

How to detect Windows shutdown or logoff in Qt

佐手、 提交于 2019-12-04 07:17:56
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. 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 call to quit() from inside the application or when the users shuts down the entire desktop session. The signal

how does readyRead() work in Qt?

倾然丶 夕夏残阳落幕 提交于 2019-12-03 15:16:38
问题 It's my first question on this website ! I have some trouble reading datas from a COM port, I send a complete message from another COM port, and when I receive it with Qt, it's always cut in multiple submessages. void SerialPortReader::init() { connect(m_serialPort, SIGNAL(readyRead()), this, SLOT(readData())); } void SerialPortReader::readData() { // m_serialPort->waitForReadyRead(200); QByteArray byteArray = m_serialPort->readAll(); qDebug() << byteArray; if(byteArray.startsWith(SOF) &&

Threaded OpenGL with shared QGLWidgets issue with Qt 5.1

a 夏天 提交于 2019-12-03 13:53:15
问题 I use two QGLWidgets. One for loading textures and one for rendering, but it is not working. I used the following explanation from http://blog.qt.digia.com/blog/2011/06/03/threaded-opengl-in-4-8/ Texture uploading thread Uploading many (or large) textures is typically an expensive operation because of the amount of data being pushed to the GPU. Again, this is one of those operations that can unnecessarily block your main thread. In 4.8 you can solve this problem by creating a pair of shared

ImportError: cannot import name 'QtCore'

自古美人都是妖i 提交于 2019-12-03 11:29:04
问题 I am getting the below error with the following imports. It seems to be related to pandas import. I am unsure how to debug/solve this. Imports: import pandas as pd import numpy as np import pdb, math, pickle import matplotlib.pyplot as plt Error: In [1]: %run NN.py --------------------------------------------------------------------------- ImportError Traceback (most recent call last) /home/abhishek/Desktop/submission/a1/new/NN.py in <module>() 2 import numpy as np 3 import pdb, math, pickle

Parse jsonarray?

て烟熏妆下的殇ゞ 提交于 2019-12-03 07:28:28
问题 I've got an JSON like the following: { "agentsArray": [{ "ID": 570, "picture": "03803.png", "name": "Bob" }, { "ID": 571, "picture": "02103.png", "name": "Tina" }] } Now I'm trying to loop through each array element. Using the qt-json library https://github.com/da4c30ff/qt-json Tried: foreach(QVariantMap plugin, result["agentsArray"].toList()) { qDebug() << " -" << plugin["ID"].toString(); } But cannot get it to work, any ideas what I'm doing wrong? 回答1: I would recommend using the QJson*