signals-slots

C++ signal to QML slot in Qt

元气小坏坏 提交于 2019-11-26 16:24:55
I want to send a Signal from C++ to a Slot in my QML File. I already got it working without and primitive type parameters, although if I want to send a QString to my QML Slot I get an error whilst connecting. I connect in main.cpp QObject *contentView = rootObject->findChild<QObject*>(QString("contentView")); QObject::connect(&myObj, SIGNAL(finishedGatheringDataForItem(QString)), contentView, SLOT(updateViewWithItem(QString))); the relavant part of my qml File Rectangle { objectName: "contentView" function updateViewWithItem(string) { console.log('got some Items'); } // slot } Error: Object:

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

99封情书 提交于 2019-11-26 16:14:29
问题 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

Determine signals connected to a given slot in Qt

六眼飞鱼酱① 提交于 2019-11-26 14:12:26
问题 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

Which C++ signals/slots library should I choose?

守給你的承諾、 提交于 2019-11-26 12:55:13
问题 I want to use a signals/slots library in a project that doesn\'t use QT. I have pretty basic requirements: Connect two functions with any number of parameters. Signals can be connected to multiple slots. Manual disconnection of signal/slot connection. Decent performance - the application is frame-based (i.e. not event-based) and I want to use the connections in each frame. I\'ve read a comparison between libsigc++ and Boost.Signals. I\'ve also read that Boost.Signals suffers from poor

Is it possible to connect a signal to a static slot without a receiver instance?

亡梦爱人 提交于 2019-11-26 09:54:25
问题 Is it possible to connect a signal to static slot without receiver instance? Like this: connect(&object, SIGNAL(some()), STATIC_SLOT(staticFooMember())); There is a QApplication::closeAllWindows() function with [static slot] attribute in Qt documentation. And there is an example of using it from the documentation: exitAct = new QAction(tr(\"E&xit\"), this); exitAct->setShortcuts(QKeySequence::Quit); exitAct->setStatusTip(tr(\"Exit the application\")); connect(exitAct, SIGNAL(triggered()),

QT : Templated Q_OBJECT class

拟墨画扇 提交于 2019-11-26 09:38:51
问题 Is it possible to have a template class, which inherit from QObject (and has Q_OBJECT macro in it\'s declaration)? I would like to create something like adapter for slots, which would do something, but the slot can take arbitrary number of arguments (number of arguments depends on the template argument). I just tried doing it, and got linker errors. I guess gmake or moc is not getting called on this template class. Is there a way to do this? Maybe by explicitly instantiating templates? 回答1:

Connecting slots and signals in PyQt4 in a loop

自古美人都是妖i 提交于 2019-11-26 08:26:33
问题 Im trying to build a calculator with PyQt4 and connecting the \'clicked()\' signals from the buttons doesn\'t work as expected. Im creating my buttons for the numbers inside a for loop where i try to connect them afterwards. def __init__(self): for i in range(0,10): self._numberButtons += [QPushButton(str(i), self)] self.connect(self._numberButtons[i], SIGNAL(\'clicked()\'), lambda : self._number(i)) def _number(self, x): print(x) When I click on the buttons all of them print out \'9\'. Why

C++ signal to QML slot in Qt

岁酱吖の 提交于 2019-11-26 04:48:18
问题 I want to send a Signal from C++ to a Slot in my QML File. I already got it working without and primitive type parameters, although if I want to send a QString to my QML Slot I get an error whilst connecting. I connect in main.cpp QObject *contentView = rootObject->findChild<QObject*>(QString(\"contentView\")); QObject::connect(&myObj, SIGNAL(finishedGatheringDataForItem(QString)), contentView, SLOT(updateViewWithItem(QString))); the relavant part of my qml File Rectangle { objectName: \

My signal / slot connection does not work

久未见 提交于 2019-11-26 00:38:21
问题 I repeatedly see people having problems with slots not being called. I would like to collect some of the most common reasons. So maybe I can help people and avoid a lot of redundant questions. What are reasons for signal / slot connections not working? How can such problems be avoided? 回答1: There are some rules that make life with signals and slots easier and cover the most common reason for defective connections. If I forgot something please tell me. 1) Check the debug console output: When

PyQt: Connecting a signal to a slot to start a background operation

杀马特。学长 韩版系。学妹 提交于 2019-11-26 00:29:09
问题 I have the following code that performs a background operation ( scan_value ) while updating a progress bar in the ui ( progress ). scan_value iterates over some value in obj , emitting a signal ( value_changed ) each time that the value is changed. For reasons which are not relevant here, I have to wrap this in an object ( Scanner ) in another thread. The Scanner is called when the a button scan is clicked . And here comes my question ... the following code works fine (i.e. the progress bar