I am writing an application in PyQt6 and have a Grid (10×10) of QButton’s with icons made from a set of images that are merged (based on needed elements) using QPainter. This renders perfectly on my development system (Windows 11, NVIDIA graphics card, PyCharm) but the button icons show up as black or with some lines of graphics but nothing identifiable as the original graphics, on my Son’s gaming system (Windows 11, AMD Radeon graphics card).
Running as an EXE created by pyinstaller.
my Icon builder code:
pm_buttonIcon = QPixmap(self.button_image_size, self.button_image_size)
painter = QPainter(pm_buttonIcon)
painter.setCompositionMode(QPainter.CompositionMode.CompositionMode_SourceOver)
painter.drawPixmap(0, 0, self.pm_no_path)
if n:
painter.drawPixmap(0, 0, self.pm_north)
if e:
painter.drawPixmap(0, 0, self.pm_east)
if s:
painter.drawPixmap(0, 0, self.pm_south)
if w:
painter.drawPixmap(0, 0, self.pm_west)
return pm_buttonIcon
The return is then made into a QIcon before using button.setIcon to update the button. Button icons are updated as part of using the app and this does change what the button shows but never seems to get it right (though it does sometimes get close enough you can tell it is trying to display the right image).
Buttons in the grid are updated using:
def update_house_view(self):
is_room = False
for x in range(0, self.house_size):
for y in range(0, self.house_size):
# eprint(4, f'Update house view for cell {x}, {y}')
cell = self.scenario.getHouseCell(x, y)
if cell is None:
self.house_button_icons[x][y] = QIcon(self.path_icon_generator(False, False, False, False))
elif cell.get('room'):
is_room = True
self.house_button_icons[x][y] = QIcon(self.room_icon_generator(cell.get('name'), cell.get('north', False), cell.get('east', False), cell.get('south', False), cell.get('west', False)))
else:
is_room = False
self.house_button_icons[x][y] = QIcon(self.path_icon_generator(cell.get('north', False), cell.get('east', False), cell.get('south', False), cell.get('west', False)))
self.house_buttons[x][y].setIcon(self.house_button_icons[x][y])
self.house_buttons[x][y].setIconSize(QSize(self.button_image_size, self.button_image_size))
I have just finished uninstalling all his graphics drivers (DDU) and then installing the latest AMD Adrenalin version. The AMD tools were not working before but are now, his games are working as expected, but my app still displays wrong.
Urugamai is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.