PDA

View Full Version : event



hgedek
12th December 2007, 13:20
bool ProgramEditor::event(QEvent *e)
{

switch(e->type())
{
case QEvent::ShortcutOverride:
keyPressEvent((QKeyEvent*)e);
break;
case QEvent::Close:
closeEvent((QCloseEvent *)e);
e->accept();
break;
default:
break;
}
return QWidget::event(e);
}

This my overloaded event function.I realized that my keyPressEvent is called twice.I tried to delete QWidget::event(e) but this time program didnt execute well.So How can I use event ? Thanks.

jpn
12th December 2007, 13:44
Hmm, what are you trying to do?

PS. Please use [code]-tags around code snippets.

hgedek
12th December 2007, 13:52
I tried to control shortcuts(button1:F1...) So I used

case QEvent::ShortcutOverride:
function.When F1 is pressed (means button1 is clicked()) I can handle but twice.It is called from QApplication file too.
But now I agreed to try that:

connect(button1,SIGNAL(clicked( )),this,SLOT(function( ))

jpn
12th December 2007, 14:03
You can assign shortcuts to actions and buttons, and there is QShortcut too..