I'm trying to align the icon to the right and center the text in a QPushButton, but I'm not satisfied with the result for now. I would also like the icon to be completely to the right of the QPushButton and not centered with the text. Likewise I would like this to work with an icon positioned to the right or left while being able to choose the width of the button. Do you have a solution ? Can you help me ? Here is my code for now:
# Les boutons du bas pour passer d'une page à l'autre
bout_pag_charg_enr_phase_1 = QPushButton("Aller directement à la page de maintenance de la Séquence")
bout_pag_charg_enr_phase_1.setFixedWidth(406)
bout_pag_charg_enr_phase_1.setIcon(QIcon('logo_png_apsc'+os.sep+'icone_3_fleches_droite_apsc_256x256.png'))
bout_pag_charg_enr_phase_1.setIconSize(QSize(16, 16))
bout_pag_charg_enr_phase_1.setLayoutDirection(Qt.RightToLeft)
bout_pag_charg_enr_phase_1.setStyleSheet("text-align: center; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #fdfbf7, stop: 1 #6190F2);border-style: solid;border-width: 2px;border-radius: 8px;border-color: #9BB7F0;padding: 3px")
bout_pag_suivante_phase_1 = QPushButton("Page suivante")
bout_pag_suivante_phase_1.setFixedWidth(120)
bout_pag_suivante_phase_1.setIcon(QIcon('logo_png_apsc'+os.sep+'icone_2_fleches_droite_apsc_256x256.png'))
bout_pag_suivante_phase_1.setIconSize(QSize(16, 16))
bout_pag_suivante_phase_1.setLayoutDirection(Qt.RightToLeft)
bout_pag_suivante_phase_1.setStyleSheet("background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #fdfbf7, stop: 1 #6190F2);border-style: solid;border-width: 2px;border-radius: 8px;border-color: #9BB7F0;padding: 3px")
What I get:
What I want:
A possible solution is to place on top and on the right side a QLabel that shows the icon.