signals-slots

QMetaObject::connectSlotsByName: No matching signal

天涯浪子 提交于 2019-11-27 15:22:51
I set a QT menu, which is automatically connected with action function on_actionOpen_triggered() . Later I want to pass a filename string to this function in order to call this function manually in a special condition. So I changed the function signature to on_actionOpen_triggered( const char *filename_in ) . After this change the program is running well, but there is a complain in terminal, QMetaObject::connectSlotsByName: No matching signal for on_actionOpen_triggered(const char*) I am wondering what happened, and how I can add arguments for this menu action functions. Thank you. Qt

How to map Qt Signal to Event in Managed C++ (C++/CLI)

柔情痞子 提交于 2019-11-27 15:18:33
问题 I'm writing a wrapper in .NET (C++/CLI) to be able to use some native C++ Qt code in .NET. How can I map a Qt signal into a managed .NET event, so that when my Qt code fires off a signal, I can bring this forward to the .NET code. My Managed class defines the event, but if I try to use the normal QObject::connect method to hook up to the signal, it requires a QObject * receiver... I guess I have to do some magic marshalling of some sorts? 回答1: Define normal unmanaged Qt event handler. From

Qt: Signals and slots Error: undefined reference to `vtable for

心不动则不痛 提交于 2019-11-27 15:00:20
Following example from this link: http://developer.kde.org/documentation/books/kde-2.0-development/ch03lev1sec3.html #include <QObject> #include <QPushButton> #include <iostream> using namespace std; class MyWindow : public QWidget { Q_OBJECT // Enable slots and signals public: MyWindow(); private slots: void slotButton1(); void slotButton2(); void slotButtons(); private: QPushButton *button1; QPushButton *button2; }; MyWindow :: MyWindow() : QWidget() { // Create button1 and connect button1->clicked() to this->slotButton1() button1 = new QPushButton("Button1", this); button1->setGeometry(10

Prevent Firing Signals in Qt

纵然是瞬间 提交于 2019-11-27 13:24:07
问题 We have a QCheckBox object, when user checks it or removes check we want to call a function so we connect our function to stateChanged ( int state ) signal. On the other hand, according to some condition we also change the state of QCheckBox object inside code, and this causes the unwanted signal. Is there any way to prevent firing signal under some conditions? 回答1: You can use the clicked signal because it is only emitted when the user actually clicked the check box, not when you manually

Argument type for Qt signal and slot, does const reference qualifiers matters?

不想你离开。 提交于 2019-11-27 13:11:32
For signal and slot of below type signals: void textChanged(const QString &); public slots: void setText(const QString & text) the type of argument of textChanged and setText seems to work invarable of const and & . Does the constant and reference qualification make any difference compared to just using QString ? QObject::connect(a,SIGNAL(textChanged(QString)),b,SLOT(setText(QString))); QObject::connect(a,SIGNAL(textChanged(const QString &)),b,SLOT(setText(const QString &))); EDIT: I did not notice the output window showing error messages when there is incompatible type being used in SIGNAL or

Can Qt signals return a value?

吃可爱长大的小学妹 提交于 2019-11-27 13:00:25
Boost.Signals allows various strategies of using the return values of slots to form the return value of the signal. E.g. adding them, forming a vector out of them, or returning the last one. The common wisdom (expressed in the Qt documentation [EDIT: as well as some answers to this question ] ) is that no such thing is possible with Qt signals. However, when I run the moc on the following class definition: class Object : public QObject { Q_OBJECT public: explicit Object( QObject * parent=0 ) : QObject( parent ) {} public Q_SLOTS: void voidSlot(); int intSlot(); Q_SIGNALS: void voidSignal();

Qt signaling across threads, one is GUI thread?

主宰稳场 提交于 2019-11-27 11:41:40
What does it mean to move a object from one thread to another in Qt using moveToThread? Everything seems to work even before using moveToThread, which moves the object from one thread (GUI thread) to a another thread ( worked) and Qt:connect calls the appropriate slot on object. Is there any difference because of where the object lives, GUI thread or the worker thread? EDIT: I made a small program, but I don't understand how QThread works along with Signal and slot function, I would appreciate if you could explain what is the use of moveToThread with the example #include <QtGui/QApplication>

PyQt proper use of emit() and pyqtSignal()

五迷三道 提交于 2019-11-27 10:48:48
问题 I am reading through some documentation on PyQt5 to come up with a simple signal-slot mechanism. I have come to a halt due to a design consideration. Consider the following code: import sys from PyQt5.QtCore import (Qt, pyqtSignal) from PyQt5.QtWidgets import (QWidget, QLCDNumber, QSlider, QVBoxLayout, QApplication) class Example(QWidget): def __init__(self): super().__init__() self.initUI() def printLabel(self, str): print(str) def logLabel(self, str): '''log to a file''' pass def initUI

Is the PySide Slot Decorator Necessary?

天涯浪子 提交于 2019-11-27 10:17:22
问题 I've seen some example code for PySide slots that uses the @QtCore.Slot decorator, and some that does not. Testing it myself, it doesn't seem to make a difference. Is there a reason I should or should not use it? For example, in the following code: import sys from PySide import QtCore # the next line seems to make no difference @QtCore.Slot() def a_slot(s): print s class SomeClass(QtCore.QObject): happened = QtCore.Signal(str) def __init__(self): QtCore.QObject.__init__(self) def do_signal

Determine signals connected to a given slot in Qt

人盡茶涼 提交于 2019-11-27 08:35:56
I've injected myself into a Qt application, and I'm attempting to figure out what signals a given slot is connected to, but can't find any information on doing this. Is there a mechanism for doing this out of the box? If so, is this exposed to QtScript? (If not, I can wrap it easily enough.) If there is no such mechanism, what would be the best way to add it? I cannot manipulate the existing application outside of simple hooking, but I could hook QObject::connect and store the connections myself, just not sure if that's the best way to go about it. I think Qt stores the slots a given signal is