問題描述
好吧,我再次嘗試使用 Qt Creator 上的 Linux GUI 應用程序,我在我的項目的 Qt 資源文件中添加了幾個圖像.我試圖在我的主窗口和其他窗口和對話框中擁有一個漂亮的背景.我使用的是樣式表選項(無編碼).
Well, I was again trying my hands on a Linux GUI app on Qt Creator, I added couple of images in a Qt resource file of my project. And I tried to have a nice background in my main window and other windows and dialogs. I was using from the stylesheets option (no coding).
我無法設置標簽和按鈕的透明度級別.關于如何從 Qt Creator GUI 本身做到這一點的任何想法???
!我附上了我的應用程序外觀的快照.
I am unable to set the transparency level of labels and pushbuttons. Any ideas on how to do it from Qt creator GUI itself ???
!I am attaching a snap of how my application looks.
推薦答案
可以通過設置樣式表來設置QLabel或者QPushbutton的透明度:
You can set transparency of QLabel or QPushbutton by setting the stylesheet :
ui->label->setStyleSheet("background-color: rgba(255, 255, 255, 0);");
ui->button->setStyleSheet("background-color: rgba(255, 255, 255, 0);");
您還可以在設計器中將 background-color: rgba(255, 255, 255, 0);
添加到小部件的 styleSheet 屬性中.
You can also add background-color: rgba(255, 255, 255, 0);
to the styleSheet property of the widget in the designer.
第四個參數是 alpha.您還可以通過將 alpha 設置為大于零的某個值來擁有半透明小部件:
The fourth parameter is alpha. You can also have semi-transparent widgets by setting alpha to some value more than zero :
ui->button->setStyleSheet("background-color: rgba(255, 255, 255, 50);");
這篇關于C++ over Qt:控制標簽和按鈕的透明度的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!