Accents don't work with native/alien widgets combination.
Roman Jarosz
kedgedev at gmail.com
Sun Feb 8 15:36:36 GMT 2009
Hi,
I find out why the international accents (e.g. áí) sometimes don't work.
Kopete bug report: http://bugs.kde.org/show_bug.cgi?id=182996
The problem is with native/alien widgets combination.
If application runs with alien widgets (let say QDialog) and we create
one native X11 widget in it (let say QTextEdit) then when the QTextEdit is
create the winId is assigned to it and everything works.
The problem shows if after while we want to move the QTextEdit into e.g.
QTabWidget.
During the move Qt creates new winId. The problem is that the X-server
still
sends the XKeyEvents for QTextEdit with old winId (not the new one) and
when in QXIMInputContext::x11FilterEvent
(qt/src/gui/inputmethod/qximinputcontext_x11.cpp)
we ask if the event should be filtered the XFilterEvent compares the new
winId
(keywidget->effectiveWinId()) with the old one (from XKeyEvent) and always
returns false.
The bug can be seen in Kopete when we create new tab, after that user
can't type
accents in first tab. The problem is that the Qt::WA_NativeWindow flag is
set
in Qt/KHTML the KHTML needs the winId for
KIO::SchedulerPrivate::registerWindow
and when it calls QWidget::winId() Qt automatically sets
Qt::WA_NativeWindow
for that window;
I probably should send this to TT right, because it doesn't look like we
use the code
wrongly?
Here is small test case (qt have to use alien widgets by default), after
5s the QTabWidget is created and after that accents don't work in QTextEdit
#include <QApplication>
#include <QtGui>
class MyDialog: public QWidget {
Q_OBJECT
public:
MyDialog() : QWidget() {
mainLayout = new QVBoxLayout( this );
mainLayout->setContentsMargins(4, 4, 4, 4);
te = new QTextEdit();
te->setAttribute(Qt::WA_NativeWindow);
te->setParent( this );
te->show();
mainLayout->addWidget( te );
this->setLayout(mainLayout);
QTimer::singleShot(5000, this, SLOT(showTabs()));
}
public slots:
void showTabs();
private:
QTextEdit* te;
QVBoxLayout* mainLayout;
};
void MyDialog::showTabs() {
QTabWidget* tw = new QTabWidget( this );
mainLayout->addWidget( tw );
tw->show();
te->setParent( tw );
tw->addTab(te, "1");
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MyDialog a;
a.resize(QSize(300, 200));
a.show();
return app.exec();
}
#include "main.moc"
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
More information about the kde-core-devel
mailing list