signals-slots

Qt Thread object only sending signal as Qt:DirectConnection - why?

徘徊边缘 提交于 2019-12-11 16:29:47
问题 I have a class derived from QThread : class MyClass : public QThread This class is connected with a slot of another object. Originally this was connected as Qt::AutoConnection . But then - as soon as the thread is started ( MyClass::run() ) - the signal is no longer "reaching the slot" ( why? ). // connected before myObject->run() s = QObject::connect( _myObject, SIGNAL(signalLogMessage(const QString&, QtMsgType)), this, SLOT(slotLogMessage(const QString&, QtMsgType)), Qt::DirectConnection);

Qt can't connect a subclass of QGraphicsView signal (not inherited) to SLOT

旧街凉风 提交于 2019-12-11 10:42:44
问题 I defined class MyGraphicsView, a subclass of QGraphicsView. Than, I add a signal test() in MyGraphicsView. In my MainWindow class, I have MyGraphicsView* myView and I connect like: connect(myView, SIGNAL( test() ) , this, SLOT( zoom() )) ; But I got: QObject::connect: No such signal QGraphicsView::test() in ..\Proto_version_2\mainwindow.cpp:73 回答1: In order to use slots and signals in a class, it must be derived from either QObject or a QObject derived class and your class must include the Q

How to combine own message loop and Qt event loop?

帅比萌擦擦* 提交于 2019-12-11 10:18:45
问题 I have a class derived from QThread: class MyClass : public QThread . In the run method I have "my own" message loop: run() { // exec(); // while not reached while (_runMessageLoop && ...) { hr = CallDispatch(.....); if (hr== 0) QThread::msleep(100); // QCoreApplication::processEvents(); // Does not work } } Since exec() is not executed, I have no Qt event loop. This obviously causes signal / slots not to work correctly. Is there any chance to combine the Qt and my own message loop? Or do I

Qt MainWindow is not updating

不打扰是莪最后的温柔 提交于 2019-12-11 08:14:35
问题 I am using Qt to generate a Window. Additionally I use libnfc to get access to a nfc reader, so far so good. In my self written nfc-class i generate a new thread, this thread is polling for new tags on the reader. If there is a new tag, the thread will start a signal event for the MainWindow. In the main window I have just a QWebView which will show different websites on different states (after start, new tag, tag removed), just realy basic stuff. My problem is now: that the main window (or

What happens to the signal/slot connection if the pointer is pointing to a new object

半世苍凉 提交于 2019-12-11 07:26:34
问题 I have a uploader with the following code: if(!_canceled) { _reply = _accessManager.put(request, item); if(_reply) { _currentItem = item; bool status = connect(_reply, SIGNAL(uploadProgress(qint64, qint64)), this, SLOT(reportUploadProgress(qint64, qint64))); pantheios::log(pantheios::debug, "StorageProvider(): connection uploadProgress(qint64, qint64), status", pantheios::boolean(status)); status = connect(_reply, SIGNAL(finished()), this, SLOT(handleFinishedRequest())); pantheios::log

Emitting a Qt::signal from worker thread makes the UI update on main thread by default?

人走茶凉 提交于 2019-12-11 07:15:42
问题 I am new to Qt . I have worker thread that is an std::thread . The worker thread function continuously fetches some some data in a loop. The size of the data is frequently updated on a Text element on a QML UI. I have a listener callback which is nothing but an std::function and it gets called from the thread's function . It sends me callbacks based on which I updated the Text element on QML . I update it using signal slot mechanism. Following is the QML : Text element: Text { id: mytext

Is it safe to disconnect a slot before it was called?

我的梦境 提交于 2019-12-11 07:01:49
问题 I have several objects which need to be updated. The updating is done in a separate thread and the results will be transferred to the objects via a pyqtSignal . So the updating method loops over all objects like this: The object class: class MyObject(QObject): def __init__(self, id): QObject.__init__(self) self.id = id def catch_result(self, id, res): if id == self.id: # do something with res And the worker class: class Worker(QObject): result = pyqtSignal('QString', 'QString') def __init__

Multi-dialog program in PyQT will not close (the sequel!)

心不动则不痛 提交于 2019-12-11 04:19:02
问题 I have another problem with PyQT, this time I have an example that will be far more useful since it contains part of my code (defanged of course!) I have a hard time figuring out how to close the 'PROGRAM SELECT' dialog window by only using the 'LOGOUT' button. I could simply use the close button on the form, but I want to do it with the 'LOGOUT' button. Could anyone help me solve this conundrum? Here is some compilable code for you all to chew on. connectionName = 'example' class

PyQt5: Using QtDesigner, how do you connect a signal with a slot/callable defined in a module

旧街凉风 提交于 2019-12-11 03:24:06
问题 I am a total beginner with PyQt5, please excuse my ignorance I am trying to connect a push button with a function that I defined import sys from PyQt5 import QtGui, QtWidgets,uic def PrintSomething (): print("Hello world") if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv) window = uic.loadUi("Auto.ui") window.show() sys.exit(app.exec_()) In order to do the above I added a slot to the MainWindow using QtDesigner ..as seen in the picture and then I connected the Pressed signal

react on the resizing of a QMainWindow for adjust widget's size

对着背影说爱祢 提交于 2019-12-11 01:11:58
问题 How do I react on the resize of a QMainWindow ? I have QTextBrowsers in a QScrollArea and I adjust them to the size of the content on creating them (the only thing that should scroll is the QScrollArea ). Everything works for now, but if I resize the mainWindow , the height of the QTextBrowsers isn't changed, because the reflow function isn't triggered. Do you have any better idea to adjust a QTextBrowser to it's content? My current code is: void RenderFrame::adjustTextBrowser(QTextBrowser* e