Method QWidget::createWindowContainer and background
Solved
QML and Qt Quick
-
I want to make Label with icon and text and a transparent background:
qml file:Item { property alias labelText: label.text Image { id: pic source: "qrc:/../../Desktop/avatar.png" } Label { id: label text: "This text should change... This text should change... This text should change... This text should change... This text should change..." width: 200 textFormat: "RichText" color: "red" font.pixelSize: 12 anchors.left: pic.right anchors.leftMargin: 10 wrapMode: Text.Wrap background: Rectangle { color: "black" radius: 5 } } }
cpp:
QQuickView* view = new QQuickView(); QWidget* container = QWidget::createWindowContainer(view, ui->centralWidget); container->setMinimumSize(320,80); container->setMaximumSize(320,80); container->setStyleSheet("QWidget {background-color: rgb(23,58,104)}"); view->setSource(QUrl("qrc:/MsgLabel.qml")); ui->verticalLayout->addWidget(container);
I try change background color of widget but nothing... How to make transparent background (white area is bad)?
-
found such a solution:
QQuickWidget* qq = new QQuickWidget(QUrl("qrc:/MsgLabel.qml"), ui->widget); qq->resize(320,80); qq->setAttribute(Qt::WA_AlwaysStackOnTop); qq->setClearColor(Qt::transparent); ui->verticalLayout_2->addWidget(qq, 0 , Qt::AlignBottom | Qt::AlignLeft);