Background color of QPushButton, in Python; Fedora vs. Ubuntu
by RockDoctor from LinuxQuestions.org on (#58S81)
Wondering what I might be dong wrong. I'm running Fedora 32 and 33, and Ubuntu 20.04 and 20.10, all updated. The code below properly colors the buttons under Fedora, but not under Ubuntu.
Code:from PyQt5.QtWidgets import (QTableWidgetItem, QLabel, QLineEdit,
QVBoxLayout, QWidget, QPushButton,QGridLayout, QTableWidget,
QFileDialog, QApplication, QHBoxLayout, QButtonGroup)
from PyQt5.QtCore import Qt
...
for idx, img in enumerate(["", "", "", ""]):
btn = QPushButton(img, self)
btn.setMaximumWidth(20)
btn.setStyleSheet("background-color: aqua")
self.xlt_grp.addButton(btn, idx+1)
hbox.addWidget(btn)Coloring the background QTextEdit works properly in all cases.


Code:from PyQt5.QtWidgets import (QTableWidgetItem, QLabel, QLineEdit,
QVBoxLayout, QWidget, QPushButton,QGridLayout, QTableWidget,
QFileDialog, QApplication, QHBoxLayout, QButtonGroup)
from PyQt5.QtCore import Qt
...
for idx, img in enumerate(["", "", "", ""]):
btn = QPushButton(img, self)
btn.setMaximumWidth(20)
btn.setStyleSheet("background-color: aqua")
self.xlt_grp.addButton(btn, idx+1)
hbox.addWidget(btn)Coloring the background QTextEdit works properly in all cases.