signals-slots

(Qt) Create signal from QButtonGroup of PushButtons?

时光毁灭记忆、已成空白 提交于 2019-12-08 08:34:53
问题 I am so confused on how this whole thing works. I have some pushbuttons that I put into a group like this: MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); AddSlotsToGroup(); } void MainWindow::AddSlotsToGroup() { QButtonGroup* group = new QButtonGroup(this); group->addButton(ui->slot_0); group->addButton(ui->slot_1); //... } And I want to create a slot that gets the id of the button that was clicked in that group. (Sorry if I

How to signal a slot in another thread in Qt

旧城冷巷雨未停 提交于 2019-12-08 06:56:26
问题 I have written a simple signal slot application using Qt. I want to send a signal to another thread that is runs out of the main thread. Here is my code: class Thread1 : public QThread { Q_OBJECT void run() { exec(); } public: Thread1(QObject* parent); public slots: void a() { qInfo()<<QThread::currentThreadId(); } }; class Object : public QObject { Q_OBJECT public: Object(){} void start() { qInfo()<<QThread::currentThreadId(); Thread1* thread = new Thread1(this); connect(this,SIGNAL(a())

Boost::Asio with Main/Workers threads - Can I start event loop before posting work?

▼魔方 西西 提交于 2019-12-08 05:59:15
问题 I'm new to Boost::Asio. I want to have a "Manager" process a lock free queue on a worker thread and send the result back to the main thread. Borrowing heavily from the answer here (Boost Asio pattern with GUI and worker thread) I've been able to get close to what I want. Here is the code: #include "stdafx.h" #include <boost/asio.hpp> #include <boost/lockfree/spsc_queue.hpp> #include <boost/signals2.hpp> #include "Task.h" class Manager { typedef boost::signals2::signal<void(int)> Signal;

QNetworkAccessManager one instance and connecting slots

六月ゝ 毕业季﹏ 提交于 2019-12-08 04:18:42
问题 I have my first Qt application in development. It's a desktop client for site messaging. Qt documentation says that i need to have only one instance of QNetworkAccessManager accross application. But i also read that using of singletons with Qt isn't a good idea. How i can make one instance of QNetworkAccessManager across app? Another question is how to properly connect slots while i call ApiHandler functions from other classes? For example i have ExampleApi class which uses functions of

pyqt: How to dynamically update widget property on outer variable value change?

倾然丶 夕夏残阳落幕 提交于 2019-12-07 14:31:38
问题 I have class Ui_MainWindow(object) that creates a window with a progress bar and class OtherClass(object) that contains method in which the local int variable increments in cycle. How to connect local variable value change to progres bar value change? mainGUI.py import sys from PyQt4.uic.Compiler.qtproxies import QtGui from PyQt4 import QtGui from Ui_MainWindow import Ui_MainWindow def main(): app = QtGui.QApplication(sys.argv) MainWindow = QtGui.QMainWindow() ui = Ui_MainWindow() ui.setupUi

Correct way to convert old SIGNAL and SLOT to new style?

ⅰ亾dé卋堺 提交于 2019-12-07 12:32:35
问题 I'm currently trying to convert an old python program from Python 2 to Python 3, and update from PyQt4 to PyQt5. The application uses the old style signal and slots that are not supported under PyQt5. I have figured out most of what needs to be done, but below are a few lines that I can't seem to get working: self.emit(SIGNAL('currentChanged'), row, col) self.emit(SIGNAL("activated(const QString &)"), self.currentText()) self.connect(self,SIGNAL("currentChanged(const QString&)"), self

Qt connect “no such slot” when slot definitely does exist

江枫思渺然 提交于 2019-12-07 04:45:20
问题 Qt v4.8.0, VC2010 compiler I have a QMainWindow based class and I'm trying to send it signals involving QUuid However, every time I run it I get the errors: Object::connect: No such slot MainWindow::on_comp_connected(QUuid) in ..\..\src\mainwindow.cpp:143 Object::connect: (receiver name: 'MainWindow') It's driving me potty as the slot definitely does exist (it's in the moc_) class MainWindow : public QMainWindow { Q_OBJECT // SNIP private typedefs public: MainWindow(QWidget *parent = 0, Qt:

Resolving conflicts with PyQt new-style signals-slots

£可爱£侵袭症+ 提交于 2019-12-07 04:21:00
问题 QComboBox has two signals, both called currentIndexChanged ; one passes the index of the selected item, and the other passes the text of the selected item. When I connect this signal to my slot, with something like self.myComboBox.currentIndexChanged.connect(self.mySlot) it gives me an index. Is there a way I can use new-style signals to indicate that I want the text returned? 回答1: See the second example in connecting signals portion of documentation. In your case it would be: self.myComboBox

Qt signals and slots for multiple objects

被刻印的时光 ゝ 提交于 2019-12-06 20:52:35
I'm having little problem here. I'm having troubles with signals & slots. I'll try to explain with pseudocode. So, here it goes. I have main thread (mainwindow.cpp) where I'm creating new objects when new client connects. mainwindow.h: signals: void changeText(); ... mainwindow.cpp: connect(tcpserver, SIGNAL(changeText()), this, SIGNAL(changeText())); ... MyClass *m = new MyClass(this); connect(this, SIGNAL(changeText()), m, SLOT(changeText())); I have also tcpserver class, which creates new QThread when client connects and connects both signals. tcpserver.h: signals: void changeText();

Qt GUI app: warning if QObject::connect() failed?

风格不统一 提交于 2019-12-06 20:32:59
问题 I recently migrated my Qt project from Linux to Vista, and now I'm debugging signals blindly. On Linux, if QObject::connect() fails in a debug build, I get a warning message on stderr. On Windows, there is no console output for GUI applications, only an OutputDebugString call. I already installed DebugView, and it catches my own qDebug() output nicely, but still no warning on failed signals. One possible solution would be to use QtCreator's autocomplete for signals, but I like Eclipse, and