Unsolved Transparent Buttons
-
On Ubuntu 16.04 Using Qt Creator 4.0.3 Based on Qt 5.7.0 I create a transparent button as follows:
darkButton = new QPushButton(this); darkButton->setText(""); darkButton->setStyleSheet("QPushButton{background:transparent;}"); darkButton->setGeometry(350,10,121,171); darkButton->show(); connect(darkButton,SIGNAL(released()),this,SLOT(on_darkButton_released()));
This works fine however on the same Ubuntu release with Qt Creator 4.0.2 the button comes up black instead of transparent.
Looking through the posts I have tried the following
darkButton->setStyleSheet("background:transparent;")
and
darkButton->setAttribute(Qt::WA_NoSystemBackground, true)
and
darkButton->setAttribute(Qt::WA_NoBackground); darkButton->setAttribute(Qt::WA_NoSystemBackground); darkButton->setAttribute(Qt::WA_TranslucentBackground);
but all of them still come up non-transparent.
Hard to believe that this is due to 4.0.2 vs 4.0.3! Could there be something else that is causing the button to be non-transparent? -
@mstoth
Please excuse my ignorance, but I am intrigued.Qt Creator lets you write C++ code. The code gets compiled and linked against a version of Qt, which in itself has nothing to do with the Creator. The effect of you writing the C++ code cannot vary depending on which Qt Creator you happened to create the source file in?
-
@mstoth said in Transparent Buttons:
Using Qt Creator 4.0.3 Based on Qt 5.7.0
The line above...
- ...tells us what version of Qt was used to build your IDE.
- ...does not tell us what version of Qt you using to build your project.
See Tools > Options... > Build & Run > Kits instead. What version(s) of Qt are available on your machine?
Note the difference between Qt (the library) and Qt Creator (the IDE)
This works fine however on the same Ubuntu release with Qt Creator 4.0.2 the button comes up black instead of transparent.
- Same machine or different machine?
- Physical machine or virtual machine?
Hard to believe that this is due to 4.0.2 vs 4.0.3! Could there be something else that is causing the button to be non-transparent?
It's plausible that an older version of Qt had a bug that was fixed in a newer version.
In fact, Qt 5.7 is quite old now. Try again with the latest Qt 5.9.2 from https://www1.qt.io/download-open-source/ (it also contains Qt Creator 4.4.1)
-
Setting a style sheet for buttons might not work unless you check the button property "flat"
-
@Gugge Thank you! you saved me.