ComServant
9th April 2009, 22:00
Here's my event filter:
bool MainWindow::eventFilter(QObject *object, QEvent *event)
{
//QEvent::MouseButtonDblClick
if(event->type() == QEvent::MouseButtonPress)
{
if(object == ui->myQTextEdit)
{
assert(0);
}
else if(object == ui->myQLineEdit)
{
assert(0);
}
}
return QMainWindow::eventFilter(object, event);
}
Here's how I'm setting it up:
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindowClass)
{
ui->setupUi(this);
ui->myQTextEdit->installEventFilter(this);
ui->myQLineEdit->installEventFilter(this);
}
When I click on the QLineEdit, the assert triggers. Good. When I click on the QTextEdit, it does not trigger. :confused: The same happens with QEvent::MouseButtonDblClick. Double clicks work on the QLineEdit, and not on the QTextEdit.
I know the filter is set up right, because using something like QEvent::Enter triggers the assert on both QLineEdits and QTextEdits. (Also, I have more than one QTextEdit, and it doesn't work on either)
And here's the odd thing, the edging around the QTextEdits are receptive to presses and double clicks and trigger the asserts. The textual part of the QTextEdits are the parts that aren't receiving them, however.
Could someone confirm the ability to capture double and single clicks on QTextEdits in Qt 4.5? What did I do wrong?
Thank you in advance.
bool MainWindow::eventFilter(QObject *object, QEvent *event)
{
//QEvent::MouseButtonDblClick
if(event->type() == QEvent::MouseButtonPress)
{
if(object == ui->myQTextEdit)
{
assert(0);
}
else if(object == ui->myQLineEdit)
{
assert(0);
}
}
return QMainWindow::eventFilter(object, event);
}
Here's how I'm setting it up:
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindowClass)
{
ui->setupUi(this);
ui->myQTextEdit->installEventFilter(this);
ui->myQLineEdit->installEventFilter(this);
}
When I click on the QLineEdit, the assert triggers. Good. When I click on the QTextEdit, it does not trigger. :confused: The same happens with QEvent::MouseButtonDblClick. Double clicks work on the QLineEdit, and not on the QTextEdit.
I know the filter is set up right, because using something like QEvent::Enter triggers the assert on both QLineEdits and QTextEdits. (Also, I have more than one QTextEdit, and it doesn't work on either)
And here's the odd thing, the edging around the QTextEdits are receptive to presses and double clicks and trigger the asserts. The textual part of the QTextEdits are the parts that aren't receiving them, however.
Could someone confirm the ability to capture double and single clicks on QTextEdits in Qt 4.5? What did I do wrong?
Thank you in advance.