qt-signals

Qt signal and slots: are reference arguments copied?

余生长醉 提交于 2020-01-23 02:15:30
问题 In qt framework, most library signals and slots use pointers as parameters. I was wondering, If I create a signal-slot "structure" that takes a reference as the parameter instead of the pointer, will the whole parameter be copied, or just 4 bytes (32-bit system) like in a regular c++ reference? I am asking this because I noticed something when I create a signal/ slot methods with the reference parameter. When I then connect them, the autocomplete mechanism in QTCreator doesn't hint me with

PyQt5 in what module is the emit method found?

落爺英雄遲暮 提交于 2020-01-07 05:03:08
问题 It would be helpful somebody run this code for me as a sanity check. Python 3.3.1 (default, Apr 17 2013, 22:30:32) [GCC 4.7.3] on linux Type "help", "copyright", "credits" or "license" for more information. >>>from PyQt5.QtCore import pyqtSignal >>>for i in dir(pyqtSignal): ... if i == 'emit': ... print(True) ... >>> Is true returned for anyone else? Note that with a QObject import from PyQt4: >>> from PyQt4.QtCore import QObject >>> for i in dir(QObject): ... if i == 'emit': ... print(True)

QT Signal / Slot

懵懂的女人 提交于 2019-12-25 01:39:03
问题 I've got a question about signals and slots. In my app, I want to connect a signal from one object to a textEdit in a dialog window. My signal emits a QString ; if I violate encapsulation (by making the UI public instead of private) and connect the signal directly to the textEdit it works. But I feel that it's not the right way. If I make something like the following: connect(m_osgWidget->picker.get(), SIGNAL(setX(QString)), m_addAgentDlg, SLOT(getX(QString))); where: void getX(QString) {

Suppress QLineEdit editingFinished signal when certain button is clicked

眉间皱痕 提交于 2019-12-24 09:31:42
问题 I have an (existing) Widget that is composed of a QLineEdit and a QToolButton. The code I'm building upon can be found here: https://github.com/wbsoft/frescobaldi/blob/master/frescobaldi_app/widgets/urlrequester.py I'm trying to add the editingFinished signal to that composed widget, which works reasonably well by creating a new signal with editingFinished = pyqtSignal() , connecting the line edit's signal to a local method and emit the custom signal from that. However, I want to suppress

Qt: Why is `QAbstractSocket::error(QAbstractSocket::SocketError)` signal not generated when internet is disconnected?

走远了吗. 提交于 2019-12-24 07:01:17
问题 I am trying to achieve a signal when the internet is disconnected for an already connected SSL socket. Here is the way I have derived the QSslSocket : struct CloudSSL::Socket : public QSslSocket { Q_OBJECT public: void ConnectSlots () { connect(this, SIGNAL(readyRead()), this, SLOT(ReceiveData())); connect(this, SIGNAL(disconnected()), this, SLOT(Disconnected())); // *** None of the above or below is invoking when internet disconnects *** connect(this, SIGNAL(error(QAbstractSocket:

How to filter image files from selected directory (which is inside listWidget)

左心房为你撑大大i 提交于 2019-12-24 01:38:08
问题 I have a problem that I don't know how to filter images from a selected directory. I usually use directory.setNameFilters({"*.png", "*.jpg"}); but in this case I can't use that because I need to use the selected directory inside a listWidget . I use signal and slot functions. I mean if I click a directory which is inside a listWidget , the images inside this directory will be displayed in another listWidget . If I click another directory it will do the same function. Please take a look my

Passing structure to signal in Qt

一个人想着一个人 提交于 2019-12-21 17:28:14
问题 I want to send a structure with a signal in Qt. How can I do this? I know how to send integers, strings, Images etc with a signal but getting confused with the structure part. I read some posts and found out about Q_DECLARE_METATYPE() but I am not understanding how to use it. typedef struct { int EmpId; QString Name; } StandardData; class Data::public QObject { Q_DECLARE_METATYPE(StandardData); signals: void SignalData(const StandardData &f_objStandardCan); } The errors I get re 1.explicit

How to find out from the slot which signal has called this slot?

偶尔善良 提交于 2019-12-21 04:32:18
问题 I mean if I have many different signals which are connected to the same slot. I saw this question but can't understand the link in the answer. Can you give me simple example? 回答1: I think you can use this method: [protected] int QObject::​senderSignalIndex() const From Qt documentation: Returns the meta-method index of the signal that called the currently executing slot , which is a member of the class returned by sender(). If called outside of a slot activated by a signal, -1 is returned.

Qt “signal undefined reference error” after inheriting from QObject

走远了吗. 提交于 2019-12-21 04:13:39
问题 I recently needed to add a signal to a class, so I changed the class to inherit from QObject and added the Q_OBJECT macro into the class definition. Since doing so I get "signal undefined reference error for 'vtable for CLICommand'" error on the class line below: // File clicommand.h #include <QString> #include <QStringList> #include <QTcpSocket> #include "telnetthread.h" class CLICommand : public QObject { Q_OBJECT public: CLICommand(TelnetThread *parentTelnetThread); signals: void signal

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

独自空忆成欢 提交于 2019-12-19 18:27:01
问题 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