PDA

View Full Version : how to catch qMouseEvent



pakine
5th July 2010, 18:16
Hi, i'm a newbie in QT, and i'm working in a proyect with it. now i need to get a simple MouseEvent but i don't get it.
There is a class called ListaMensajes where QScrollArea is placed. Inside i can load PanelTx objects.
The idea is to select the PanelTx object by clicking over each one.



protected:
void clickPanelTxEvent(QMouseEvent *e);

private:
Ui::PanelTxClass ui;


and the definition ..



PanelTx::PanelTx (CArincMsgData *msg, ListaMensajes &listaMensajes, QWidget *parent)
: QWidget(parent), m_cListaMensajes (listaMensajes), m_pMessage (msg)
{
ui.setupUi(this);

m_pDialogPropiedades = 0;

loadValues ();

colorPanelTx(m_pMessage->isEnabledTx ()); //poner color activo-desactivo
}

PanelTx::~PanelTx()
{

}
.............

void PanelTx::clickPanelTxEvent(QMouseEvent *e)
{

if (e->button() == Qt::LeftButton)
{

//this line is just to check it works
this->setPalette(QPalette(Qt::white));

}
else if (e->button() == Qt::RightButton)
{
......
}
}


the line:
this->setPalette(QPalette(Qt::white));
works perfectly with this widget cause im using it in other parts, but i can't get the handler work for the QMouseEvents

could anybody help me?
thanks