PDA

View Full Version : how to catch "click" signal on the dialog



fulbay
16th February 2011, 10:29
Hello,

I want to catch "click" signal when the mose is clicked on a dialog, so that, I will implement a slot. Is there a way to do that?

Thanks for help...

venkateshhegde
16th February 2011, 10:49
Code attached:

5963

Basically You define a Signal in your dialog H File:
///////////////////
signals:
void clicked();
/// It could be any name....
///////////////////

Then You go a little deeper and define a function in the dialog H File

virtual void mousePressEvent ( QMouseEvent * event );

and define it as
void MainWindow::mousePressEvent ( QMouseEvent * event )
{
emit clicked();
}

And Lo! You have your own SIGNAL that can be attached to any slot!

fulbay
16th February 2011, 12:27
Many many thanks for your help! :)