[Qt-interest] transparent child blocking events to the parentwidget.

Ulf-Alexander v. Ceumern-Lindenstjerna ceumern at vrmagic.com
Wed Jan 13 11:35:38 CET 2010


Well  your transparent widget completely covers your parent widget.
While it is rendered transparently, it still receives all input events.
If you want the parent widget to receive the events you have to manually
forward them yourself.

Think of your transparent widget as a glass window you can look through,
but you still cannot touch what you see...

Cheers, Ulf

> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> bounces at trolltech.com] On Behalf Of manish.s.sharma at nokia.com
> Sent: Wednesday, January 13, 2010 11:16 AM
> To: qt-interest at trolltech.com
> Subject: [Qt-interest] transparent child blocking events to the
> parentwidget.
> 
> Hi all,
> 
> I am creating a widget containing some lineedits and creating another
> transparent widget and setting this transparent widget as child of the
> widget containing the lineedits. Now when I do a show on the parent
> widget and try to click on the lineeditors I cannot click it seems the
> transparent child widget is consuming all the events. Isn't this a
> wrong  bahaviour? What I was expecting was since the child widget is
> transparent event should be going to the parent widget. I think it is
a
> bug or am I missing something fundamental?
> 
> Below is the code to reproduce the problem.
> 
> #include <QApplication>
> #include <QLineEdit>
> #include <QVBoxLayout>
> 
> int main(int argc, char** argv)
> {
>     QApplication app(argc, argv);
> 
>     QWidget *widget = new QWidget;
>     QVBoxLayout *layout = new QVBoxLayout;
>     layout->addWidget(new QLineEdit);
>     layout->addWidget(new QLineEdit);
>     layout->addWidget(new QLineEdit);
>     widget->setLayout(layout);
> 
> 
>     // creating a transparent widget and setting this widget as child
>     // of above widget
>     QWidget *transparentWidget = new QWidget;
>     transparentWidget->setAttribute(Qt::WA_TranslucentBackground);
>     transparentWidget->resize(widget->geometry().size());
>     transparentWidget->setParent(widget);
> 
>     widget->show();
>     app.exec();
> }
> 
> 
> Regards,
> Manish
> 
> 




More information about the Qt-interest-old mailing list