No warnings!!
I'm able to catch the signal from CWorker then pass it on till homeWidget. But the otherway isn't working.
No warnings!!
I'm able to catch the signal from CWorker then pass it on till homeWidget. But the otherway isn't working.
Then it makes me think that signal and slot are not connected, and hence not being called. Show us somthingI'm able to catch the signal from CWorker then pass it on till homeWidget. But the otherway isn't working.
When you know how to do it then you may do it wrong.
When you don't know how to do it then it is not that you may do it wrong but you may not do it right.
Pls find the flow of signal from homeWidget to slot in cworker:
In chomewidget.cpp:
Qt Code:
connect(m_pbScan, SIGNAL(clicked()), this, SIGNAL(scanBtnClicked())); // this connect is in constructor of homeWidget.cppTo copy to clipboard, switch view to plain text mode
In centralWidget.cpp:
Qt Code:
homeWidget = new CHomePage(); connect(homeWidget, SIGNAL(scanBtnClicked()), this, SIGNAL(scanBtnClicked())); // again in constructor // used similar name for signal in centralWidget.cpp againTo copy to clipboard, switch view to plain text mode
In cmainwindow.cpp
Qt Code:
centralWidget = new CCentralWidget(); // QStackedWidget connect(centralWidget, SIGNAL(scanBtnClicked()), worker, SLOT(onScanBtnClick()));// in constructorTo copy to clipboard, switch view to plain text mode
In cworker.h
Qt Code:
public slots: void onScanBtnClick();To copy to clipboard, switch view to plain text mode
In cworker.cpp
Qt Code:
void CWorker::onScanBtnClick() { qDebug("Scan Button Clicked from UI"); }To copy to clipboard, switch view to plain text mode
Thank you.
What is a CHomePage and what would make it emit scanBtnClicked?
Yes, I did QObject::moveToThread(). I started the secondary thread in qmainwindow.
The slot which I'm trying to call is not in the loop. It need not be in this case.
Qt Code:
worker = new CWorker(); worker->moveToThread(thread); connect(thread, SIGNAL(started()), worker, SLOT(pollSharedMemory())); connect(trayIcon, SIGNAL(quitButtonClicked()), thread, SLOT(quit())); connect(trayIcon, SIGNAL(quitButtonClicked()), worker, SLOT(deleteLater())); connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); shrdMemorySignals(); thread->start();To copy to clipboard, switch view to plain text mode
CHomePage is one of the widgets on QStackedWidget. QStackedWidget is set as central widget to QMainWindow. So I need to detect the button click signal in CWorker slot (this slot is not running in loop, so need to catch that signal.
Thank you.
Last edited by rawfool; 17th June 2013 at 06:09.
and pollSharedMemory() is not running an infinite loop, right?
Cheers,
_
It's in infinite loop: while(1). With 2 secs sleep.
Now Santosh suggested me to use QTimer from mainwindow itself instead by removing while(1). And timer->moveToThread(thread);
As of now it's working fine.
EDIT: BTW Any ideas ?
Last edited by rawfool; 17th June 2013 at 16:09.
I'm polling shared memory content, so I created a slot which check the change in data of shared memory & emits a signal. Based on this signal, I disable/enable some widgets.
And on click events in some widgets, I need to update values of the shared memory (this signal, I wasn't able to receive).
For ore clarity, I've described my architecture in post #1.
Thank you for your interest anda_skoa.
That is no where near structure, how can it be architecture? It is a just enough to wear thinking cap.For ore clarity, I've described my architecture in post #1.
When you know how to do it then you may do it wrong.
When you don't know how to do it then it is not that you may do it wrong but you may not do it right.
When you say CWorker is in a secondary thread, have done that using QObject::moveToThread() or by creating it inside run()?
Is the secondary thread's event loop running?
Cheers,
_
Bookmarks