I'm trying to set a style to a button so that it has no border, but it seems the lack of border then makes the button non-clickable. Is there a better way of getting no border?
button = QtGui.QPushButton(todo, self)
button.move(0, i * 32)
button.setFixedSize(200,32)
button.setCheckable(True)
button.setStyleSheet("QPushButton { background: rgb(75, 75, 75); color: rgb(255, 255, 255); text-align: left; font-size: 12pt; border: none;}")
EDIT: WHOOPS, just noticed this is a Question regarding Qt/Python (and not Qt/C++), well maybe my answer helps anyways..
Just tried it, and it works for me...
Here is the code i used:
#include <QtGui/QApplication>
#include <QtGui/QPushButton>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget w;
QPushButton* button = new QPushButton("i am toggleable", &w);
button->setFixedSize(200,32);
button->setCheckable(true);
button->setStyleSheet(
"QPushButton { \
background: rgb(75, 75, 75);\
color: rgb(255, 255, 255);\
text-align: left;\
font-size: 12pt;\
border: none;\
}\
QPushButton:checked {\
background: rgb(105, 105, 105);\
}\
");
w.show();
return a.exec();
}
notice i added a additional CSS rule for checked buttons, so it gets visible if a Button is checked or not. Are you sure your buttons dont work, or could it be, that you just dont see that they are working ?!
EDIT2: If it doesnt work for you, you could just use setFlat(True)
, and use additional CSS rules to fix the colors (like in my example).