signals-slots

QML : How to read a QList from C++

孤街醉人 提交于 2019-12-14 01:51:37
问题 I have a simple need : I have defined a C++ class class MyClass: public QDeclarativeItem { Q_OBJECT public: MyClass(QDeclarativeItem * parent=0); ... private: QList<QString> mList } And of course, I've registered it : qmlRegisterType<MyClass>(...) I want to access in the QML code to my QList<QString> mList . How can I do it? It annoys me as it looks like a simple problem, but I can't find anything about this. (I can create a Q_INVOKABLE slot, but I can't read the results, etc...) Edit : QML

Qt- How to use connect between incompatible signal and slot

点点圈 提交于 2019-12-13 20:27:53
问题 I am trying to do a game. In this I want to call a function, that function will receive a point . But this function should be invoked by a timer's timedout signal. Can anybody say how to achieve this. Below is the required/error code Point p(a,b); connect(timer,SIGNAL(timedout()),this,startDestruction(p)); Can anybody say how to achieve this? 回答1: Create a method to use as an intermediate slot, like this. Point p(a,b); connect(timer, SIGNAL(timedout()), this, q); q() { startDestruction(this-

Signal QWebPage::loadFinished(bool) returns twice?

戏子无情 提交于 2019-12-13 19:08:34
问题 I got a problem with QWebPage::loadFinished (bool) signal , it calls back twice , is that normal ? ( there's no link following at all , e.g HTTP status 302 ) Consider the following code , the whole thing may cause problem , is trying to load another link within that slot , will this be a problem ? If i do a qDebug() << thisUrl; each time in loadFinished(bool) slot , i could see it for 3 times , is that normal , one for url XXX , and two for url YYY , and the last two links are exactly the

Follow an emitted signal to its connected slot(s)?

别说谁变了你拦得住时间么 提交于 2019-12-13 17:53:14
问题 I understand that a Qt signal is put onto the event queue, and then the connected slots are called later when the event loop sees it. So it doesn't make sense to "step into" it when debugging. But I really do want to see, in a large enough app that I can't keep all of it in mind at once, where the control flow ends up. So is there a way to find the slot(s) that are connected to a signal, either potentially based on connect(...); calls or actually at the moment when debugging? In Qt Creator 3

PyQt5: How can I connect a QPushButton to a slot?

◇◆丶佛笑我妖孽 提交于 2019-12-13 11:33:05
问题 Okay, so pretty much every tutorial/understandable-written-in-human-language-documentation is for PyQt4. But, PyQt5 changed how the whole 'connect button to a slot' works, and I still can't figure it out how to do it. I did a quick gui in QtDesigner, and I have a QPushButton and a label. When I click the button, I want the text on the label to change. in C++ in QtDesigner, It's easy to connect the two. But I have to write it all in python. I convert .ui file with pyuic5 to .py file. There, in

Qt slot from thread called more than once [duplicate]

假装没事ソ 提交于 2019-12-13 10:26:19
问题 This question already has answers here : Slot is being called multiple times every time a signal is emitted (1 answer) Qt Signals and Slot connected twice… what happens? (3 answers) Closed 3 years ago . I have created a class CalculationManager which has a public slot process() emitting a signal finished(). void CalculationManager::process() { cout << "calc FFT: process()" << endl; ... emit finished(); } This is used with a QThread from the gui (calculationManager is a QScopedPointer) void

QML QObject destroyed before being able to process a signal

天涯浪子 提交于 2019-12-13 05:59:18
问题 In QML, I'm using a C++ library that returns a QObject that does a process and emits a signal when is done. In javascript, I use the connect method of the signal being emitted ( success ) to attach an anonymous function that should handle the signal as the following piece of code shows: var requestResponse = apiClient.execute(reqInp); requestResponse.success.connect(function success(response) { var requestResponseJSON = JSON.parse(response.responseAsJsonString()); this.append(response

How to debug a failing signal/slot connection?

淺唱寂寞╮ 提交于 2019-12-13 00:18:50
问题 I am following the Chapter 2 of Jasmin Blanchettes book C++-GUI-Programming-with-Qt-4-1st-ed.pdf trying to setup the dialog GoToCellDialog using MS VS 2008 with Qt. The example compiles, the dialog appears, but it fails to enter the handler method on_lineEdit_textChanged() on text changes. To prove it, i added this line to the slot method: label->setText(tr("Changed :")); to force a visual change in the label. In the .ui file the element <connections/> is empty. I don't know why. I decided to

How to create pyqtSignals dynamically

核能气质少年 提交于 2019-12-12 12:33:15
问题 Is there any possibility to create signals at runtime when needed? I'm doing something like this in a function: class WSBaseConnector(QObject) def __init__(self) -> None: super(QObject, self).__init__() self._orderBookListeners: Dict[str, pyqtSignal[OrderBookData]] = {} def registerOrderBookListener(self, market: str, listener: Callable[[OrderBookData], None], loop: AbstractEventLoop) -> None: try: signal = self._orderBookListeners[market] except KeyError: signal = pyqtSignal(OrderBookData)

Is this method of inter-thread-communication safe?

心已入冬 提交于 2019-12-12 09:43:08
问题 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