[Qt-interest] transparent widget can't have parent widget
cheng long
kevinclcn at gmail.com
Wed May 19 12:46:32 CEST 2010
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100519/aa60d747/attachment.html
More information about the Qt-interest-old
mailing list