signals-slots

Is this method of inter-thread-communication safe?

梦想与她 提交于 2019-12-10 08:39:20
问题 I have 3 objects(inherited from QObject ) that each contain a separate std::list . Each object gets created in the main gui thread (with no parent) and then is pushed to it's own thread (using Qt's QObject::moveToThread() ). Each thread is hooked up to a gui and messages are sent between the different threads with data. Each thread is to essentially handle it's own list. For example: Obj 1 : Consumer of data. It pop's the front off of its list(if data is present) to use. It also has a SLOT

QTimer::singleShot() looks for the specified slot in the given object's parent class, not the object itself

吃可爱长大的小学妹 提交于 2019-12-09 15:59:30
问题 I am fairly new to Qt. I have done some simple modifications to an existing Qt application, but I haven't created any from scratch yet. I also don't have really much experience with certain aspects of C++ in general (class inheritance etc). I have created a new Code::Blocks Qt4-based project and modified the template a bit. I have added two files. Right now the project contains three files: main.cpp, app.h and app.cpp. This is the content of main.cpp : #include <QTimer> #include "app.h" int

Qt can I connect signals/slots to self in constructor?

六眼飞鱼酱① 提交于 2019-12-09 13:07:35
问题 EDIT: Not related to signals/slots/connect. Problem was constructor calling constructor. There might be a better way to do this - I'd be interested in hearing those... I have MyClass that is derived from a QLabel. I want to pass more data about the derived class back in the signal than what the base signal does. So I made a slot to intercept the customContextMenuRequested signal and emit a revised one that has more data. When I try to connect up this signal in the constructor, then my slot

pyqt dynamic generate QMenu action and connect

╄→гoц情女王★ 提交于 2019-12-09 12:54:10
问题 Still learning how pyqt works. I want to dynamically generate a customContextMenu and connect with a function. So far I got the following but the connect part not working ? import sys from PyQt4 import QtGui, QtCore class MainForm(QtGui.QMainWindow): def __init__(self, parent=None): super(MainForm, self).__init__(parent) # create button self.button = QtGui.QPushButton("test button", self) self.button.resize(100, 30) # set button context menu policy self.button.setContextMenuPolicy(QtCore.Qt

How to connect a signal to a slot

◇◆丶佛笑我妖孽 提交于 2019-12-09 03:56:31
问题 I let Qt-Creator to generate me a basic window app using Qt. I added there a button and try to connect it to a slot. It compiles fine but the app crashes and returns 3, please help me, I don't know what to do. #include "form1.h" #include "ui_form1.h" #include <iostream> Form1::Form1(QWidget *parent) : QMainWindow(parent), ui(new Ui::Form1) { connect(ui->buttonLoad,&QPushButton::clicked,this,&Form1::ButtonLoadClick); ui->setupUi(this); } Form1::~Form1() { delete ui; } void Form1:

Qt - no such signal error

巧了我就是萌 提交于 2019-12-09 03:08:26
问题 I'm trying to trigger a signal when a double click happens in one of the draggable widgets on the fridge magnets example. Here's the changes I made to the example source: DragLabel: class DragLabel : public QLabel { public: DragLabel(const QString &text, QWidget *parent); QString labelText() const; public slots: void testSlot(){qDebug()<<"testSlot";} //<-- implemented this slot protected: void mouseDoubleClickEvent(QMouseEvent *ev){emit testSignal();} //<-- overriden this method private:

Qt Signal/Slots sending a complete structure

江枫思渺然 提交于 2019-12-08 21:17:13
问题 I am attempting to send a structure via signals/slots between two threads, my signals/slots are connected properly and I have been able to send QStrings containing parts of my data but now I need to send the whole thing and Structures seem most sensible. However when I try the signal is not sent/recieved. The problem seems to be only with sending/receiving the structure, the processing before and after I have tried many ways. I cannot use pointers such here or here as my data is generated too

Is it possible to create a signal for when a QTreeWidgetItem checkbox is toggled?

左心房为你撑大大i 提交于 2019-12-08 15:33:13
问题 I've created a checkbox that's also a QTreeWidgetItem using the code below. //Populate list QTreeWidgetItem *program = createCheckedTreeItem(QString::fromStdString(itr->first), true); treePrograms->addTopLevelItem(program); QTreeWidgetItem* ConfigDialog::createCheckedTreeItem(QString name,bool checkBoxState) { QTreeWidgetItem *item = new QTreeWidgetItem(QStringList(name)); item->setFlags(item->flags()|Qt::ItemIsUserCheckable); if (checkBoxState) { item->setCheckState(0,Qt::Unchecked); } else

how to pass arguments to a function using a predefined SIGNAL in PyQT

不想你离开。 提交于 2019-12-08 13:31:29
问题 lets suppose you have 3 QRadioButtons instances inside a class self.Option1 = QRadioButton() self.Option2 = QRadioButton() self.Option2 = QRadioButton() (for brevity i didn't wrote the entire script) and you want to use them to execute a particular function when the user clicks it, so you do self.connect(self.Option1,SIGNAL("clicked()"), self.myFunction) self.connect(self.Option2,SIGNAL("clicked()"), self.myFunction) self.connect(self.Option2,SIGNAL("clicked()"), self.myFunction) How do i

Signals and Slots PyQt clarification

五迷三道 提交于 2019-12-08 11:58:22
问题 I have noticed that there are a lot of users, myself included, who don't quite grasp the concept of signals and slots in Qt. I was hoping to get some clarification on the following: #I have a function that runs as soon as the GUI is built, this takes the information from #a list and puts it into a string which is then uploaded to a texbox. At the bottom of this #loop, I want it to call a function in the parent thread via signals and slots, as #recommended by other users. class MainWindow