[Qt-interest] signaling to a different QDialog ?

Scott Aron Bloom Scott.Bloom at sabgroup.com
Tue Dec 2 17:14:00 CET 2008


Im going to assume the following...

1) You have a custom QApplication derirved class where winEventFilter is
working.
2) You have a custom QDialog derived (or QWidget derived) class that is
the GUI

You need a signal in your QApplication called
"sigMeasurementReceived(values)" obviously you can name it anything you
want

In your winEventFileter() simply emit the signal

In your Dialog c++ file, include <QApplication>

#include <QAPplication>

In the constructor for your dialog simply do the following

MyDialog::MyDialog(....) : QDialog(...)
{

  connect( qApp, SIGNAL( sigMeasurementRecieved(valueTypes) ), this,
SLOT( slotMeasurementRecieved(valueTypes) ) )
}

qApp is globally defined to point to the applications QApplication
derived class.  

You will also need to define your slot

MyDialog::slotMeasurementRecieved(....)
{
}}




Good luck

Scott




> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> bounces at trolltech.com] On Behalf Of mpv
> Sent: Tuesday, December 02, 2008 7:55 AM
> To: qt-interest at trolltech.com
> Subject: [Qt-interest] signaling to a different QDialog ?
> 
> Hi,
> 
> I am relatively new to QT and I am using it for a data acquisition
project.
> My device sends a Windows message when new data is available, and I
hook
> this message with QApplication::winEventFilter.
> I would like to signal this back to the dialog in the program that
started
> the measurement with QT's signal/slot mechanism, but I am having
trouble
> getting this to work.
> All examples of the connect() call that I have seen handle objects
that are
> part of the same QDialog.
> Is there an example of e.g. a signal originating from a QApplication
object
> connecting to a slot in another QDialog ?
> Is this at all possible ?
> 
> At present, I use global stuff to handle this situation, which is not
very
> elegant.
> 
> Regards, Matt
> 
> 
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list