qt-signals

qt signal undefined reference error

那年仲夏 提交于 2019-12-03 05:14:42
I have a class server for which I have created a signal joined(QString name). I call it in a function called join(QString name), however I'm getting the error Server.o: In function Server::join(QString)': Server.cpp:(.text+0x48): undefined reference to Server::joined(QString)' collect2: ld returned 1 exit status This is what my header file looks like: #ifndef SERVER_H #define SERVER_H #include <QString> #include <mqueue.h> #include <QVector> #include <QStringList> #include "../src/messages.h" class Server { public: Server(); void start(); private: void join(QString name); char buf[MSG_SIZE],

Substitute for sleep function in Qt/C++

廉价感情. 提交于 2019-12-02 15:39:35
问题 So I am writing a program that displays each letter of a word for 1 second with a 1 second interval between the letters. (It's for a spelling exercise for grade 1). I am currently using the sleep function to "pause" the program for 1 second before it "updates" again. After that it displays the word for a second and then removes it. I repaint before the sleep function, else it does not seem to update in time. Here is the basic function: QString word = "apple"; QThread thread; for(int i = 0; i

How do I assert the identity of a PyQt5 signal?

早过忘川 提交于 2019-12-02 10:13:00
问题 I'm in a situation where I want to assert the identity of a PyQt5 signal. Specifically, I want to check whether the clicked signal from a given QPushButton object is identical to a signal that is stored in a variable named signal . The following snippet illustrates the situation: from PyQt5.QtWidgets import QApplication, QPushButton app = QApplication([]) widget = QPushButton() signal = widget.clicked widget.clicked == signal Out[1]: False widget.clicked is signal Out[2]: False id(widget

Qt: Connecting protected QListWidget::itemChanged signal to a slot

不羁的心 提交于 2019-12-02 03:41:24
问题 I used below syntax in Qt5 according to new connect syntax to avoid type mismatches of slot and signals for a a QListWidget with checkable items. connect(item, &QListWidget::itemChanged,this , &mainWindow::checkItemChanged); I want to run my slot in case any of list item changed its state. In order to this this I used itemChanged signal due to this answer, but it is protected and compile time error raise as below: error: ‘void QListWidget::itemChanged(QListWidgetItem*)’ is protected How can I

How to pass a QString to a Qt slot from a QMenu via QSignalMapper or otherwise

自古美人都是妖i 提交于 2019-12-01 17:07:46
I have a QMenu with many submenus. These are dynamically created i.e. the names menus come from a db and created in a loop. Now i wanted to fire the same slot triggered() or similar when a menu is clicked, but i needed the QString menu name to be passed to slot so i could perform menu specific actions. I have tried this i.e. passing a QAction * to the triggered event and used setData but i am getting the run time error. object::connect: No such signal QAction::triggered(QAction *) for(int j=0; j<channelTypes[i].getNumChannels() ; j++){ QAction *subMenuAct = subMenu->addAction(tr(c_name)); // c

Qt: Return value of signal works, why is the official doc saying it is impossible / forbidden?

此生再无相见时 提交于 2019-12-01 16:09:28
Qt documentation says, return values of signals are not possible: Signals are automatically generated by the moc and must not be implemented in the .cpp file. They can never have return types (i.e. use void). Related SO questions: Can Qt signals return a value? Qt: meaning of slot return value? However, from my trials (Qt 4.8.1) I can tell return values do work: If signal / slot are in the same thread, ConnectionType may be Qt::AutoConnection With signal / slot in different threads I need to use Qt::BlockingQueuedConnection So in my code I call a signal by QString dp = emit WscAircrafts:

Qt: Return value of signal works, why is the official doc saying it is impossible / forbidden?

大兔子大兔子 提交于 2019-12-01 15:02:23
问题 Qt documentation says, return values of signals are not possible: Signals are automatically generated by the moc and must not be implemented in the .cpp file. They can never have return types (i.e. use void). Related SO questions: Can Qt signals return a value? Qt: meaning of slot return value? However, from my trials (Qt 4.8.1) I can tell return values do work: If signal / slot are in the same thread, ConnectionType may be Qt::AutoConnection With signal / slot in different threads I need to

PyQt - QComboBox connection confirmed but function is not being called

扶醉桌前 提交于 2019-12-01 01:05:42
I am having a bit of trouble with the signal/slot issues using PyQt. My code is below, but it probably deserves a bit of explanation. The first two QObject.connect() return True, so I know the connection is established. However, when changing the selection in the comboBox, the function getParameters is not called as expected. The 5 connects below that were for debugging and testing the other signals associated with ComboBox. Those do not print the the log as expected either. From what I've read else where there are newer ways to specify a connection, could this be the issue? And if so, can

PyQt - QComboBox connection confirmed but function is not being called

梦想的初衷 提交于 2019-11-30 19:32:40
问题 I am having a bit of trouble with the signal/slot issues using PyQt. My code is below, but it probably deserves a bit of explanation. The first two QObject.connect() return True, so I know the connection is established. However, when changing the selection in the comboBox, the function getParameters is not called as expected. The 5 connects below that were for debugging and testing the other signals associated with ComboBox. Those do not print the the log as expected either. From what I've

Qt/C++: Signal for when a QListWidgetItem is checked?

a 夏天 提交于 2019-11-30 17:42:29
In my form I have a QListWidget which contains checkable QListWidgetItems . I'm looking for a way to capture the event of a QListWidgetItem being checked/unchecked. I don't see any such signal existing for this but maybe I'm wrong. What I'm currently doing is using the QListWidget::itemClicked() signal and checking the checkState of the QListWidgetItem , but this isn't what I want because this event happens any time the item is clicked, not just went the checkmark is toggled. Can anyone give some assistance? Thanks! jkerian Apparently no such signal is provided, your best bet is to use