[Qt-interest] transparent widget can't have parent widget
Denis Akhmetzyanov
dakhmetzyanov at smartlabs.tv
Wed May 19 13:04:27 CEST 2010
Hi,
As far as I know, attribute Qt::WA_TranslucentBackground is applicable to
the top-level widget only (i.e. without parent). The good reference for this
topic is Qt Quarterly http://doc.trolltech.com/qq/
*Issue 29 · Q1 2009, Translucent Widgets in Qt*
2010/5/19 cheng long <kevinclcn at gmail.com>
> I created a transparent QWinWidget and set the a CView as its parent, but
> the QWinWidget has an item in the task bar and it can be shown, hidden and
> closed regardless of the CView.
>
> Environment: Qt 4.5.2, Visual Studio 2008, Windows 7,
> Code:
> QWinWidget* pQWinWidget = new QWinWidget(pWnd); // pWnd is a CView
> pointer
> pQWinWidget->setWindowFlags(Qt::FramelessWindowHint);
> pQWinWidget->setAttribute(Qt::WA_TranslucentBackground);
>
> QHBoxLayout *pQHBoxLayout = new QHBoxLayout(pQWinWidget);
> pQHBoxLayout->setMargin(0);
>
> QGraphicsScene* scene = new QGraphicsScene();
> QGraphicsView* view = new QGraphicsView(pQWinWidget);
> pQHBoxLayout->addWidget(view);
>
> view->setScene(scene);
> view->setMinimumWidth(300);
> view->setMinimumHeight(300);
> view->setRenderHints(QPainter::Antialiasing |
> QPainter::TextAntialiasing);
> view->setStyleSheet("background: transparent");
>
> QGraphicsTextItem* text = new QGraphicsTextItem();
> scene->addItem(text);
> text->setPlainText("hello Qt!");
>
> pQWinWidget->show();
>
> If I comment these two lines below, the QWinWidget will exist as the
> CView's child.
> pQWinWidget->setWindowFlags(Qt::FramelessWindowHint);
> pQWinWidget->setAttribute(Qt::WA_TranslucentBackground);
>
> Any suggestions?
>
> Thanks,
> Kevin
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
--
Best regards,
Denis Akhmetzyanov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100519/800cfa4f/attachment.html
More information about the Qt-interest-old
mailing list