Sorry, it still failed!Just try this code if it works -
Put it in ctor of your custom widget.Qt Code:
label->setFixedSize(400,300); tb->setStyleSheet("background-color : transparent ; color:white;"); tb->addAction("Action 1"); tb->addAction("Action 2"); tb->addAction("Action 3"); tb->resize(label->width(),tb->height()); layout->addWidget(label);QLabel *label = new QLabel(); label->setFixedSize(400,300); label->setPixmap(QPixmap("some_pic.JPG").scaled(label->size())); QToolBar *tb = new QToolBar(label); tb->setStyleSheet("background-color : transparent ; color:white;"); tb->addAction("Action 1"); tb->addAction("Action 2"); tb->addAction("Action 3"); tb->resize(label->width(),tb->height()); QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(label);To copy to clipboard, switch view to plain text mode
You can also replace the stylesheet line with this one -
Qt Code:
tb->setStyleSheet("QToolBar { background-color : rgba(200,0,0,100) ; color:white; border-color: transparent;} QToolButton{background-color : transparent;} ");tb->setStyleSheet("QToolBar { background-color : rgba(200,0,0,100) ; color:white; border-color: transparent;} QToolButton{background-color : transparent;} ");To copy to clipboard, switch view to plain text mode
I doubt its the display difference between QLabel::winId and QLabel. I don't know the display mechanism of them......
Bookmarks