Python Forum
PyQt6 QAction with icon and string
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PyQt6 QAction with icon and string
#1
I cannot get a QAction initialized with a icon to show the text/string it's supposed to. Here's what I have (simple):
write = QIcon('./images/write_icon.png')
QAction(write, 'Write', self)
That's just an excerpt, I have more actions that go on a toolbar, but QActions that are just strings work fine. When I add an icon, the string doesn't show up. I don't know if the docs are written in a language I don't understand, because I can't see how that shouldn't work.

Any ideas?

EDIT:
setText() and setIconText() doesn't make a string show either. I forgot to add that in initial post.
Reply
#2
Is your action in a toolbar?

Then you can use

toolbar.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
Reply
#3
(Sep-12-2022, 11:52 AM)Axel_Erfurt Wrote: Is your action in a toolbar?

Then you can use

toolbar.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
Boom! That did it. My action is in a toolbar, and it was set to IconOnly. I didn't even know that feature existed.
Thanks @Axel_Erfurt!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] Saving file to html or pdf stopped working in PyQt6 ejKDE 4 536 Mar-12-2024, 07:45 PM
Last Post: ejKDE
  [PyQt] [solved] How to display a pdf-file in a PyQt6 widget BigMan 13 16,273 May-06-2023, 09:27 AM
Last Post: Axel_Erfurt
  event driven coding PyQt6 on Combobox change merrittr 3 2,088 May-03-2023, 03:35 AM
Last Post: merrittr
Question [PyQt] Application desktop toolbar with PyQt6 bunz 4 1,531 Mar-09-2023, 08:09 PM
Last Post: bunz
Exclamation [PyQt] Setting icon on QAction from outside QGuiApplication gradlon93 3 1,741 Jan-04-2023, 11:37 AM
Last Post: gradlon93
  [PyQt] QAction bold part of the string argument malonn 4 2,309 Sep-12-2022, 05:00 PM
Last Post: malonn
  how to remove icon ilyess68ysl 4 3,731 Oct-15-2021, 10:05 AM
Last Post: ilyess68ysl
  [PyQt] Embed Google Maps in PyQt6 Widget Raures 2 3,129 Sep-11-2021, 04:32 PM
Last Post: Raures
  Icon in tkinter menator01 8 5,011 May-03-2020, 02:01 PM
Last Post: wuf
  [Tkinter] Password Reveal Icon Evil_Patrick 2 4,687 Nov-29-2019, 02:20 PM
Last Post: Evil_Patrick

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020