Python Forum
How to get the color name of qlistwidget?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get the color name of qlistwidget?
#1
Hi,

I'm trying to get the color name of the current item's foreground of a qlistwidget.

To set it I used:
self.listbox_medium.insertItem(0, "paper")
self.listbox_medium.item(0).setForeground(QColor("blue"))
To get the color name I tried:

    def button_apply_selection_clicked(self):
        if self.listbox_medium.currentItem().foreground().color().colorNames() == QColor("blue"):
            print("okay")
        else:
            print("bad")
In the listbox (qlistwidget) I've got 2 items:
one with a blue foreground,
one with a green foreground.

But if I try to check for "blue" or "green", it is always returned "bad"...

I couldn't find the correct syntax for checking for the color names...

Could you please give me a hint?

Thanks a lot...
Reply


Messages In This Thread
How to get the color name of qlistwidget? - by flash77 - Aug-13-2023, 03:25 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  QListWidget, no item was selected flash77 4 1,224 Aug-02-2023, 09:31 AM
Last Post: Axel_Erfurt
  GUI Problem / call another function / fill QListwidget flash77 5 1,099 Jul-30-2023, 04:29 PM
Last Post: flash77
  [PyQt] populate a QListWidget devilonline 1 1,781 Apr-10-2023, 02:52 AM
Last Post: deanhystad
Question [PyQt] CSS Styling for a QLabel inside a QListWidget Alfalfa 2 5,375 Nov-30-2020, 02:59 AM
Last Post: Alfalfa
  Why QListWidget doesn't show new line? AlekseyPython 3 3,532 Feb-05-2019, 02:23 PM
Last Post: AlekseyPython

Forum Jump:

User Panel Messages

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