[Qt-interest] post Event from external phidgets function

S. Aguinaga sa_jr at yahoo.com
Tue Feb 23 23:57:57 CET 2010


So I tried the following without success:

[code]
int InputChangeHandler(CPhidgetEncoderHandle ENC, void *usrptr, int Index, int State)
{
        printf("Input #%i - State: %i \n", Index, State);
 QKeyEvent* e = new QKeyEvent( QEvent::KeyPress, Qt::Key_F7, 0, 0 );
QApplication::postEvent(qApp, e );

        return State;
}
[/code]

And below, ConfigurationPage is the Class where my QLabel (that I want to edit when the phidget button, a USB device, is pressed)
is located (GUI running or main thread).

[code]
int InputChangeHandler(CPhidgetEncoderHandle ENC, void *usrptr, int Index, int State)
{
        printf("Input #%i - State: %i \n", Index, State);
 printf("Change the Colors of the Patient Response box.\n");
ConfigurationPage *taWidgObject = new ConfigurationPage;
//taWidgObject->patientResponse();
QKeyEvent* e = new QKeyEvent( QEvent::KeyPress, Qt::Key_F7, 0, 0 );
QApplication::postEvent( taWidgObject, e );

        return State;
}
[/code]




________________________________
From: S. Aguinaga <sa_jr at yahoo.com>
To: Qt Interest <Qt-interest at trolltech.com>
Sent: Mon, February 22, 2010 5:49:23 PM
Subject: [Qt-interest] post Event from external phidgets function




Hello fellows, 

Is it possible to post an Event from a canned Phidgets function, so that it will be processed by my Event Handler in my Qt class?   I want to change the QLabel listed below when the Phidget button is pressed, but right now I'm getting errors because of  threading.

Phidget function inside the same cpp file as my class definition:

int InputChangeHandler(CPhidgetEncoderHandle ENC, void *usrptr, int Index, int State)
{
        printf("Input #%i - State: %i \n", Index, State);

// initiate an Event here  using QCoreApplication::postEvent( .... )  
// that can be processed as a keypress event ( 

       return State;
}

The above function is in my file where the class is defined:

#include <XXX>
<skip>
MyQtClass::MyQtClass(QWidget *parent)
: QWidget(parent)
{

// CPhidget related object creation (etc)
// QLabel I want to modify when the Phidget (USB button) is pressed

responseTimer = new QLabel(tr("Patient Response")); 

... <skip>
}

void MyQtClass::keyPressEvent( QKeyEvent *event) 
{
...
}



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100223/97d1b205/attachment.html 


More information about the Qt-interest-old mailing list