qtcore

QSerialPort is causing a program stop (endless loop?) if opening device

Deadly 提交于 2019-12-01 09:05:16
I want to write on a serial device. Unfortunately I have the feeling the QSerialPort is not properly implemented under linux. In contrast to other methods (python) I get !sometimes! a hang of the program when I try to call: serial.open(QIODevice::ReadWrite) I am using the example from http://qt-project.org/wiki/QtSerialPort (see below). The QSerialPortInfo is working properly so that I can search for my device before I open it. The problem appeared in all Qt 5.* series. I am currently using 5.3 beta from the OpenSuse repository. Other tools or methods proof, that the device is working (Windows

QSerialPort is causing a program stop (endless loop?) if opening device

旧巷老猫 提交于 2019-12-01 05:51:59
问题 I want to write on a serial device. Unfortunately I have the feeling the QSerialPort is not properly implemented under linux. In contrast to other methods (python) I get !sometimes! a hang of the program when I try to call: serial.open(QIODevice::ReadWrite) I am using the example from http://qt-project.org/wiki/QtSerialPort (see below). The QSerialPortInfo is working properly so that I can search for my device before I open it. The problem appeared in all Qt 5.* series. I am currently using 5

How to specify compiler flag to a single source file with qmake?

倖福魔咒の 提交于 2019-11-30 20:22:28
While other source files use the default flags? Some of my source files need some extra C++ preprocessor defines. I use Qt 5. I only found QMAKE_CXXFLAGS is for global use in qmake projects. lpapp This is what used to be done in theory for GUI painting in the Qt source itself: SOURCES_NOOPTIMIZE = somefile.cpp nooptimize.name = nooptimize nooptimize.input = SOURCES_NOOPTIMIZE nooptimize.dependency_type = TYPE_C nooptimize.variable_out = OBJECTS nooptimize.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_IN_BASE}$${first(QMAKE_EXT_OBJ)} nooptimize.commands = $${QMAKE_CXX} $(CXXFLAGS) -O0 $(INCPATH

Difference between QObject::connect vs connect methods

跟風遠走 提交于 2019-11-30 17:36:18
I am a newbie with Qt. Most of the times Qt developers need to use signals and slots for object communication. I have seen two ways of connecting signals and slots so far. 1)QObject::connect(scrollBar, SIGNAL(valueChanged(int)),label, SLOT(setNum(int))); 2)connect(scrollBar, SIGNAL(valueChanged(int)),label, SLOT(setNum(int))); What is the exact difference between both of them? Why do we have to prefix QObject in the first method? lpapp You call the static version in both aforementioned cases, the signature of which is as follows: QMetaObject::Connection QObject::connect(const QObject * sender,

How to specify compiler flag to a single source file with qmake?

我们两清 提交于 2019-11-30 16:59:00
问题 While other source files use the default flags? Some of my source files need some extra C++ preprocessor defines. I use Qt 5. I only found QMAKE_CXXFLAGS is for global use in qmake projects. 回答1: This is what used to be done in theory for GUI painting in the Qt source itself: SOURCES_NOOPTIMIZE = somefile.cpp nooptimize.name = nooptimize nooptimize.input = SOURCES_NOOPTIMIZE nooptimize.dependency_type = TYPE_C nooptimize.variable_out = OBJECTS nooptimize.output = ${QMAKE_VAR_OBJECTS_DIR}$

How to set Input Mask and QValidator to a QLineEdit at a time in Qt?

狂风中的少年 提交于 2019-11-30 09:25:44
I want a line edit which accepts an ip address. If I give input mask as: ui->lineEdit->setInputMask("000.000.000.000"); It is accepting values greater than 255. If I give a validator then we have to give a dot(.) after every three digits. What would the best way to handle it? lpapp It is accepting value greater than 255. Absolutely, because '0' means this : ASCII digit permitted but not required. As you can see, this is not your cup of tea. There are at least the following ways to circumvent it: Write a custom validator Use regex Split the input into four entries and validate each entry on its

Difference between QObject::connect vs connect methods

只谈情不闲聊 提交于 2019-11-30 01:26:04
问题 I am a newbie with Qt. Most of the times Qt developers need to use signals and slots for object communication. I have seen two ways of connecting signals and slots so far. 1)QObject::connect(scrollBar, SIGNAL(valueChanged(int)),label, SLOT(setNum(int))); 2)connect(scrollBar, SIGNAL(valueChanged(int)),label, SLOT(setNum(int))); What is the exact difference between both of them? Why do we have to prefix QObject in the first method? 回答1: You call the static version in both aforementioned cases,

QSettings::IniFormat values with “,” returned as QStringList

旧时模样 提交于 2019-11-29 12:30:24
I am using QSettings to parse an ini file: QSettings cfg(path, QSettings::IniFormat); When I obtain a value QVariant qv = cfg.value("title"); containing a comma the variant contains a QStringList instead of a QString title=foo => QString title=foo,bar => QStringList How can I always get strings, or at least obtain the original line ( title=foo,bar ) ? You have at least two ways to address this issue, all of them presented below: test.ini title="foo,bar" title_unquoted=foo,bar main.cpp #include <QSettings> #include <QDebug> int main() { QSettings settings("test.ini", QSettings::IniFormat); //

Copy path to QString

混江龙づ霸主 提交于 2019-11-28 10:53:35
问题 I need to copy the full filepath, without filename, into a QString from QFileDialog below. QString fileName = QFileDialog::getOpenFileName(this, tr("Select app to install"), '/' , tr("APK Files (*.apk)")); 回答1: You use QString QFileInfo::absolutePath() const for this. See the documentation for details. QFileInfo fileInfo(QFileDialog::getOpenFileName(this, tr("Select app to install"), '/' , tr("APK Files (*.apk)"))); qDebug() << fileInfo.absolutePath(); 来源: https://stackoverflow.com/questions

Why QVector::size returns int?

六眼飞鱼酱① 提交于 2019-11-28 10:46:44
std::vector::size() returns a size_type which is unsigned and usually the same as size_t , e.g. it is 8 bytes on 64bit platforms. In constrast, QVector::size() returns an int which is usually 4 bytes even on 64bit platforms, and at that it is signed, which means it can only go half way to 2^32. Why is that? This seems quite illogical and also technically limiting, and while it is nor very likely that you may ever need more than 2^32 number of elements, the usage of signed int cuts that range in half for no apparent good reason. Perhaps to avoid compiler warnings for people too lazy to declare