qtcore

Qt serial port: write and read data

廉价感情. 提交于 2019-12-11 14:26:44
问题 I'm able to connect to my serial port, but I need to read data from it all the time. It's working for about 39 minutes, but after it stops at line serial.flush() . When I stop Qt and start it again it also stops at serial.flush() . I need to restart my modem to let it work again... I'm not sure I'm executing this properly... // Open Serial connexion QSerialPort serial; serial.setPortName("usbserial-26214A"); serial.open(QIODevice::ReadWrite); serial.setBaudRate(QSerialPort::Baud115200);

Connect: No such Slot QTreeView

时间秒杀一切 提交于 2019-12-11 13:33:56
问题 I have inherited a class MainTree from QTreeview maintree.cpp file void MainTree::LaunchTree() { //Tree launching connect(this, SIGNAL(customContextMenuRequested(const QPoint& )),this,SLOT(showCustomContextMenu(const QPoint&))); } void MainTree::showCustomContextMenu(const QPoint &pos) { //Add actions } But i get the following error QObject::connect: No such slot QTreeView::showCustomContextMenu(const QPoint&) I could not understand why, am i missing something ?? Definition of the class

Compiling QObject-derived class on the command line on Linux

你。 提交于 2019-12-11 04:03:54
问题 I am new to Qt. I am trying to compile a small code snippet shown below: #include<QtCore/QtCore> #include<QtCore/QObject> class Test:public QObject { Q_OBJECT public: Test(){qDebug()<<"CTOR";} }; int main() { Test t; return 0; } I am trying to run it through command line using the following command: g++ -o signalTest.exe -l QtCore signalTest.cpp However I am getting the following error: undefined reference to vtable for Test I think I need to include the library for QObject , but I am not

Using the operator<< with a QStringList pointer

风流意气都作罢 提交于 2019-12-11 03:37:51
问题 How I can change this code? QString s="123"; QStringList *myList=new QStringList; myList<<s; Error: no match for 'operator<<' (operand types are 'QStringList*' and 'QString') *myList<<s; does not work too: myList is Empty, after this. 回答1: There is little to no point in using a pointer for a QStringList because this is an implicitly shared class due to the copy-on-write. You can find further details for that below: http://qt-project.org/doc/qt-5.1/qtcore/implicit-sharing.html Which means, I

Qt avoid warning 'QProcess: destroyed while process still running

与世无争的帅哥 提交于 2019-12-10 15:44:34
问题 Simplest code: void test { QProcess p; p.start("sleep 10"); p.waitForBytesWritten(); p.waitForFinished(1); } Of course, the process can't be finished before the end of the function, so it displays a warning message: QProcess: Destroyed while process ("sleep") is still running. I want this message not to be shown - I should destroy the process by myself before end of function, but I can't find how to do this correctly: p.~QProcess(), p.terminate(), p.kill() can't help me. NOTE: I don't want

How to change the current working directory?

僤鯓⒐⒋嵵緔 提交于 2019-12-10 15:06:51
问题 I am working on a program that takes a file from a certain directory and copies it to the working directory of Qt to be read by my application. Right now, my current path is: /Users/softwareDev/Desktop/User1/build-viewer-Desktop_Qt_5_4_0_clang_64bit-Debug/viewer.app/Conents/MacOS/viewer To get this, I used: qDebug() << QDir::current().path(); and confirmed this directory with: qDebug() << QCoreApplication::applicationDirPath(); My question is, how would I go about changing this path? 回答1:

QTableView disable sorting for some columns

随声附和 提交于 2019-12-08 12:35:18
问题 I am using QtableView(qt5.9) with 10 columns and want to disable sorting for 2nd and 3rd (only some) columns when the user clicks on the header of these columns. I use setsortingenabled flag to make my QtableView allow sorting Is there any signal which I should listen to on clicking of header and then call some appropraite method or deny sorting. 回答1: You can use the header signal sortIndicatorChanged to restore the current sort indicator. Example: connect(m_poTableView->header(),

Emitting QVector reference in Qt signal results in copy

被刻印的时光 ゝ 提交于 2019-12-08 01:42:41
问题 I'm trying to slog my way through building an application to talk to a linescan camera. Ultimately, I want to pass a "block" (i.e., array) of 384x128 unsigned short values every 100ms from a QThread (data acquisition) to a QRunnable (data processing). This means the QRunnable will have 100ms to process the data before the next block arrives. I'm still not sure the right way to move the data around. Right now, I'm using a QVector. In Qt4, I understand implicit sharing to mean that a QVector

What is the right way for an object to have a collection of a QObject derived class?

六眼飞鱼酱① 提交于 2019-12-07 18:18:48
问题 I'm trying to make a class exposing a collection(or several) of a QObject derived class(with its own qt properties) qt properties I can use in qml. According to http://qt-project.org/doc/qt-5.0/qtcore/qobject.html#no-copy-constructor-or-assignment-operator qt doesn't play well with copy constructors. So I used QList<QObject derived class> (my first idea) I can't pass the list by reference(or at least I think thats what the compiler errors implies)(needs copies) and am having a hard time

Emitting QVector reference in Qt signal results in copy

落爺英雄遲暮 提交于 2019-12-06 10:20:55
I'm trying to slog my way through building an application to talk to a linescan camera. Ultimately, I want to pass a "block" (i.e., array) of 384x128 unsigned short values every 100ms from a QThread (data acquisition) to a QRunnable (data processing). This means the QRunnable will have 100ms to process the data before the next block arrives. I'm still not sure the right way to move the data around. Right now, I'm using a QVector. In Qt4, I understand implicit sharing to mean that a QVector would not be copied if emitted in a signal, until the object is written upon. However, in a small test