Qcombobox item color. I want that text to be RED, yeah I mean font.



Qcombobox item color. A combobox may be editable, allowing the user to modify each item in the Mar 19, 2012 · QCombobox - disable an item but still retain it in the list is it possible to disable a single item (or more if I so choose) in a QCombobox. itemDelegate ())). I am on Windows 8, python3. Tagging "QComboBox Apr 28, 2023 · Try to use the QComboBox as main selector when using the pseudo classes, and use selected instead (since the popup selects items when they are hovered): QComboBox::item and QAbstractItemView::item:hover. png my code change border color: Oct 12, 2018 · I need to change the drop-down button background of the QComboBox when the mouse hover on QComboBox. In order to change the font size, I created a QComboBox with some point sizes. I wan it to be something rgb(242,243,243 but it has default color i. I do not want to remove an item from the list just gray it out or so it cant be selected. It's almost like you propose, but you have to change the role to Qt::TextColorRole. When we set border to the combo box it is continuous although we can change it. Nov 11, 2019 · What i have tried is setting my combobox's stylesheet. As you can see on the pictures I gave , my items are blue but when selected the item displayed is in grey or dark grey. QComboBox:editable { background-color : red; } QComboBox QAbstractItemView { border : 2px solid blue; border-radius: 6px; } This is the 3rd photo style sheet. Below code attempting to do that. Change background color of the line edit widget 4. Mar 5, 2013 · I want to change the text color of a QComboBox depending on the selection done by the user: If the selected item is not valid at this time it shall be displayed in red. Add items, handle user selection, and customize behavior easily Jul 15, 2021 · I'd need it to increase the line height for each item, and to alter the hover background color (as well as give them a border radius): Bonus: tips to restore the drop down arrow would be much appreciated, cause every time i touch the background property of QComboBox::drop-down, they die a quick death. I have already tested wysota's QwwColorComboBox. I did this using the following code: @ QPalette palette = combo->palette (); palette. Apr 2, 2020 · In this article we will see how we can set the background color to the combo box when mouse hover over it. But it would be great to know how to deal with background too. "I'm trying to change the colour of a QComboBox" Of the items or what do you mean? If you change color of whole combox it Nov 11, 2019 · What i have tried is setting my combobox's stylesheet. I would like to either remove or apply a background-color to the popup menu qt stylesheet qcombobox Custom QComboBox with css. Dec 8, 2016 · Gi Im not sure what you are trying. Nov 11, 2019 · I would like to change the background color of the selected item in my QCombobox's drop down list. I have tried the following style sheet: QComboBox QAbstractItemView::item:hover {color: black;background: white } But this and too many tried CSS code hasn't worked. QComboBox ¶ class QComboBox ¶ The QComboBox widget combines a button with a dropdown list. i want to draw tow lines in my Qt widget, when the QComboBox cbx is set at the item 1, the first line is set to r Jul 9, 2020 · EDIT And I would like one more thing: When I choose "two" I would like that the choosen background item will be in the same color ( red ). Thanks Jul 23, 2013 · 3answers 13kviews Style QComboBox popup menu margin Qt 4 After countless hours trying to style a QComboBox, I'm stuck with the top and bottom margin where the items are inserted. In this article, we will explore various features of QComboBox, from creating and populating it to customizing its appearance and May 7, 2015 · QComboBox style for choosed item in drop-down list General and Desktop qcombobox qt5 qss 2 Posts 2 Posters 8. Mar 8, 2013 · Hi, i have here a QCombobox with the itmes Black and Red. However, I am not sure how to go about doing it. My code looks like: Hi, Can I change the appearance of the drop down area that lists the items in terms of color of selector, margin/padding between items (particularly increase Oct 3, 2021 · PySide6 has a huge library of widgets, including buttons, checkboxes, list boxes, and sliders or dials. Whereas in by case, I am trying to change the highlight color when a signal is invoked. Now i want to have for the item Black a black background and for Red and so on. The same is for other complex item-based classes such as QCompleter (when using the popup) or QCalendarWidget (also shown in QDateTimeEdit with the popup enabled). For example: if selected first item then background should be green, if second one is selected then red. 0, pyqt5. It looks like this role is now obsolete using PySide2 and has no effect. Ensure that your customizations in both places work harmoniously. I have Comboboxes which only show highlighted items in green with a white text color. The difference to other questions is that I do not want to style "selected" item (hovered over), but to style the already Apr 21, 2017 · but then the style for "QComboBox:item:selected" and "QComboBox:item:hover" doesn't work 0 S SGaist Jun 11, 2016 · 0 I am using Qt 5. How to set item color and font in qcombobox? In drop down list (tree) that element (item) is blue (highlighted) and bold, however when I select that item its text becomes black again and font is regular (not bold) which is default for all the items in the combobox. Nov 11, 2019 · how do i go about using this? Do i use it as a stylesheet? or using setView? Selection-background-color refers to the highlighted color while selection-color refers to the font? please advice thank you! May 4, 2020 · In this article we will see how we can set background color to the down arrow of combo box. Jul 14, 2020 · Hi I tried to fix the hover color of the comboBox but it is not working . How to change the ComboBox back color, selected items and Font color - VB. It is widely used in various GUI applications, especially when dealing with settings, preferences, or selecting from predefined choices. 0 Jan 26, 2023 · Currently, the text in the Qcombobox has no padding when inactive and the padding is applied as soon as I click upon the dropdown. This background color only appear when mouse hover over the combo box widget. I would like to put the disabled item in red. Here is style:- @ QComboBox QAbstractItemView::item{padding: 10px;background-co Mar 8, 2015 · Hi, I use QComboBox, I want to change the background color of pull down menu to white (defaut is gray). How can I select an item in a combobox? How can i change the color of an item? Jul 9, 2020 · Hello, I would like something like that: When I add next item to QComboBox, I would like to set its background color ( don't change that later ). In order to add background color to the line edit part of the combo box, do the following - 1. I implemented a stylesheet to make the background transparent when nothing is changed (i. Im trying to change the background color of each item (one diferent color for each item) in a combobox. 1234 on 19 Nov 2019, 04:58 #13 @qt-1234 said in Change QComboBox popup highlighted item background color: I have a solution to this. Sep 17, 2024 · What is QComboBox? The QComboBox widget is a combination of a line edit and a drop-down list. Add line edit widget to the Nov 11, 2019 · What i have tried is setting my combobox's stylesheet. Thanks. Mar 16, 2024 · My goal is to create a slow transition animation of QComboBox items when hovering over them - I want it to slowly transition from gray color (QColor(198, 198, 198)) to white (QColor(255, 255, 255)) Hi, I would like to change the background color of the selected item in my QCombobox's drop down list. Dec 8, 2016 · Hi there , I'm trying to change the colour of a QComboBox . A combobox may be editable, allowing the user to modify each item in the list. It enhances user experience by offering a clean and efficient way to select one item from a list. QtGui. Nov 11, 2019 · @JonB i realize it will only work if the highlight is invoked using a mouse event. Within the css for the QComboBox you can call out these other PyQt objects and style them. ui->comboBox->addItem("item " + QString::number(i)); Then, when we click the button, a message box will popup to give information about the item that's currently selected. It works, my combobox turns white but its apparence looks like Windows XP Combobox My goal is to change the color of my combobox's background while keeping its Windows 10 appearance. Pleas Jan 30, 2014 · The problem is that whatever color the QComboBox currently is is what the highlight color will be when selecting an item in the popup. Is there some other way to set it? I'm wondering if this behaviour originates I had this issue. Ideally we would just modify the QStyleOptionViewItem's palette and call Feb 2, 2024 · Hi how can I change the grey default background color of a combobox? Of the selected Item not the dropdown list Any help?. How can i realize i Sep 20, 2007 · My Qt version is 4. Aug 5, 2016 · I would like to change background of a ComboBox based on selected item. So how can I change the textcolor of not selected items? Do I have to change the stylesheet for QAbstractItemView? Thanks for your answers Detailed Description A QComboBox provides a means of presenting a list of options to the user in a way that takes up the minimum amount of screen space. Please advice. I in Aug 12, 2025 · The default delegate for QComboBox is based on QItemDelegate (print (self. After some investigating I realized that the "selection-background-color" tag was correct, but it wasn't on the correct object. Feb 7, 2011 · Try creating and setting a custom item delegate. Aug 11, 2021 · Hi ! I would like to turn a combobox in white. Yes to currentIndexChanged. How to change it back to white? I did not find it in property. png I check no change item and set border color red: Screenshot_2. The QComboBox is a simple widget for presenting a list of options to your users in PyQt, taking up the minimum amount of screen space. 8k Views 1 Watching May 4, 2021 · QComboBox uses an internal QStandardItemModel (unless another model is explicitly set) which allows setting some properties for each item ("index") of the model. The solution I found (which follows) is to set a QItemDelegate on the QComboBox and overload the paint method. Example: EDIT And I would like one more thing: When I choose "two" I would like that the choosen background item will be in the same color ( red ). Any hints? Thanks in advance Aug 17, 2022 · How can I change the color of the text inside the ComboBox. Down arrow is the button part of the combo box which is when pressed opens the list view of items. I know that I can use QLineEdit Apr 2, 2020 · By default combo box is of grey color although we can change its color. Sep 27, 2021 · But when I click the QComboBox to check the list, the round shape is not created. Thank you. Mar 8, 2013 · Right, been here and done this ;o) The issue is complicated somewhat by the fact that a QComboBox drop down is actually a QAbstractItemView with an associated model which makes styling things rather difficult. I would like to add background color to certain rows of a combobox. For that case, you need to derive the QLineEdit widget used for the editing and reset its background. Dec 8, 2016 · Hi , I' already changed the color of the items I put in my combobox the thing is when the list is not opened , I cannot see the item selected because it won't change color. Imagine a restaurant menu (the QComboBox). Set up any Sep 21, 2022 · 转载自QComboBox样式设置 - 知乎 (zhihu. The placeholder text is only visible when no item is selected. In order to do this we have to change the style sheet code of the combo box, below is the style sheet code - QComboBox::editable { background-color : lightgreen; } Below is the implementation Oct 10, 2017 · I used this code to disable an item inside a combobox Disable specific items in QComboBox (it's ok) And I would like a visual feedback. A combobox is a selection widget that displays the current item, and can pop up a list of selectable items. e. Jun 6, 2018 · It doesn't do that for me when i click on a item in the combo box rest of the items color won't change to the current selected item's color. In order to do this we have to change the style sheet code of the combo box, below is the style sheet code. This means that the previously selected item text stays visible and the user has to click elsewhere in the windows to make the text of the newly selected item appear in the combo. Create a line edit widget 3. not selectable, no highlights when mouse hovering above, and the texts are greyed out) in the QComboBox when certain conditions are met. net#Combobox #Backcolour #Comboboxcolours The PySide. Before : After: Thanks for helping ! Jan 26, 2024 · How to change QComboBox items' height Asked 6 years, 10 months ago Modified 8 months ago Viewed 9k times Jul 11, 2019 · 0 I am trying to style a QCombobox in the QT Designer, but for the life of me I cannot get this issue to stop happening. If I write: QComboBox::drop-down:hover It would be wrong because it is a selector to hover over Sep 12, 2019 · cbo. After I move the cursor on the dropdown list, the hovered item gets dark blue, and there is Sep 12, 2024 · How can I change the color of an item in a QListWidget Aug 2, 2022 · how do I add some style for the selected element (in this case for 1)? For example, how to paint the background of the selected element in red? Here is the code from PyQt5 import QtWidgets from PyQt5. Initialize it with no items in the list (it's an empty dropdown to start). Thanks Jan 6, 2021 · Before: It is Dropdown, inside comboBox, it is white color background. " like in the picture). Perhaps this is the reason for Jérôme's answer. The border is round, but the background doesn't seem to be the case. I have the ui set to have a black background, and I can't seem to style the ComboBox so that when I click the arrow for the drop-down I can actually SEE the list of items beside the highlighted one. In order to do this we have to change the style sheet associated with the combo box, below is the stylesheet code QComboBox { border : 2px black; border-style : dotted; } Below is the implementation Apr 25, 2025 · Learn how to create a color picker using Python and PyQt. May 27, 2025 · In essence, QComboBox::currentData () returns the data that you've previously associated with the currently selected item in the dropdown menu. It can pop up a list of selectable items. ComboBox->setStylesheet ("QComboBox { selection-background-color: rgb (0,255,0); }"); or i have to use item delegate in this case? Nov 6, 2012 · Also have a problem regarding QComboBox, I think it was already mentioned. comboBox. 1 I am trying to change the background color and text color for an element when the cursor is on that element. Jul 13, 2020 · Hello, I would like to change text color in QComboBox like this: ( I only want red text "Text abcd…. Every time the combo box was selected (the item of focus in the GUI) the box would be blue with white text. Installing PyQt Before getting Apr 1, 2009 · Hi everybody, I would like to build a combobox for selecting colors, like the one used in MS Excel when you select for example the color of a line. Below is the implementation. Great, so time to call your post as solved? Please do May 27, 2025 · In essence, QComboBox::addItem () is a function in Qt that allows you to add a new item to a dropdown list, which is what a QComboBox widget represents. Style Sheet Usage Customizing the Foreground and Background Colors Let's start by setting yellow as the background color of all QLineEdit s in an application. In Qt (and most User Interfaces), widget is the name given to a component of the UI that the user can interact with. This could be achieved like this: Jun 13, 2022 · The QComboBox is kind of like a QLineEdit (Active Selection), QPushButton (Down Arrow) and a QListView (Drop Down List) all together to make the QComboBox. I figured out how to change the color, w Nov 28, 2022 · I want to distinguish the placeholder text of a QComboBox using QStyleSheet by drawing the placeholder with a different color. Something is temporarily overriding the BG colour. com) QComboBox组件构成 设置下拉三角符号时,样式不成功的原因。 "QComboBox::drop-down {width: 15px;border-left-width: 0px;}"中border-left Aug 16, 2018 · I'm trying to change the color of the combobox background. What is the correct way? May 19, 2016 · What I need: Once a row/color is selected, I would like the combo box to show the color. QComboBox, a versatile widget in PyQt6, provides a drop-down list of options for users to choose from. In order to do this we have to change the style sheet code of the combo box, below is the style sheet code - QComboBox::hover { background Apr 18, 2025 · Learn how to use the QComboBox widget in PyQt6 to create dropdown menus in your GUI applications. I would also like to apply padding to the QAbstractItemView so the text does not overlap and has some spacing between the items. ComboBox->setStylesheet ("QComboBox { selection-background-color: rgb (0,255,0); }"); or i have to use item delegate in this case? In my application, I want to disable some items (i. QtWidgets. This program allows users to select a color from a dropdown and change the main window's background color accordingly. Until here nothing very difficult , I changed the colour as green blue and the background colour Oct 7, 2008 · While the previous answers may set the background color for a non-editable QComboBox, they do not work for an editable QComboBox. Oct 22, 2024 · User interaction is a crucial aspect of any GUI application. More … Inherited by: QFontComboBox Synopsis ¶ Properties ¶ countᅟ - The number of items in the combobox currentDataᅟ - The data for the current item currentIndexᅟ - The index of the current item in the combobox Feb 25, 2020 · When my QComboBox is in drop down state it highlights the previously selected item with a blue background. In this example the choosen item text is "one" ( I think about that "one" above beacuse there are 2 x May 4, 2020 · In this article we will see how we can set the background color to the line edit part of combo box, line edit part of the combo box is in which text is shown and edit. To achieve that, use an ItemTemplate. qt. ComboBox->setStylesheet ("QComboBox { selection-background-color: rgb (0,255,0); }"); or i have to use item delegate in this case? In classic CSS, when font and color of an item is not explicitly set, it gets automatically inherited from the parent. This background color only appear when combo box widget get pressed. io May 27, 2025 · Example 1: Changing the Background Color of the Selected Item In this example, we'll create a custom ComboBox that highlights the background of the currently selected item with a specific color. QComboBox widget is a combined button and popup list. Rogina replied to qt. The docs say to use ForegroundRole but that didn't do anything for me either. I'd like it blue so we can see it. Jul 11, 2012 · I can't find a standard way to disable an individual item in a Qt combo box. In order to do this we have to change the style sheet code of the combo box, below is the style sheet code QComboBox::pressed { background-color Nov 11, 2019 · What i have tried is setting my combobox's stylesheet. I want to style the highlighting of chosen item in drop-down of combobox. In this example the choosen item text is "one" ( I think about that "one" above beacuse there are 2 x Is it possible to create a combo-box item first, then set its display properties (such as background-color, icon, font-color, font-size, etc) and only then add it to the combo-box using QComoboBox. StyleSheet maybe. I want it to be white, but I can't make it have any color different from gray. I tried the following, but it says "Invalid property name 'style'", and I get the error "ComboBoxStyle is May 27, 2025 · Conflicting with Item Delegate If you're also using a custom item delegate (setItemDelegate ()) for your QComboBox, the drawing logic in the delegate's paint () method might conflict with the style options you're setting in initStyleOption (). Oct 29, 2015 · Info: Qt 4. The trouble is with QComboBox. I have managed to change the highlight colour of the actual input box but when the drop down appears it is still blue. A combobox may be editable and can contain icons. A PySide. With Qt6, it's easy to set the placeholder text to a combo box from co Dec 8, 2016 · Hi , I' already changed the color of the items I put in my combobox the thing is when the list is not opened , I cannot see the item selected because it won't change color. I have a QComboBox in my program with 5 items + 1 blank (default) item. The picture on top is what I'm getting, and the one on the Jan 27, 2011 · Hello All, Can someone guide me on how to remove border around text on hover. Thanks for your replys. Doesn't work, the selected item is still gray. Jul 17, 2014 · Is there really no way to have the stylesheet affect individual items in the list view that pops up when you click on a combo box? I tried this: @ QComboBox QAbstractItemView::item:hover { background: red; } @ but it doesn't work. Combobox is non-editable. In order to add color to the down arrow we have to change the style sheet associated with the combo box, below is the style sheet code QComboBox::down-arrow { background-color : lightgreen; } Below is the Dec 24, 2015 · On the screenshot you can see that second from bottom QComboBox has Missing text in it. Thanks for the reply. The QComboBox::setItemDelegate () function is the way you tell your combo box to use a specific artist (your custom item delegate) instead of its default painter. Jun 21, 2010 · Basically I want the combo boxe's font color to be white. I would like each QComboBox item to stay the same color. I wrote it for testing. Nov 11, 2019 · Hi, I would like to change the background color of the selected item in my QCombobox's drop down list. 6. Great, so time to call your post as solved? Please don't forget to mark it as such. Jul 31, 2018 · I assumed, that QComboBox QAbstractItemView::item would adress the items of the popup, but no matter what I write there, it does not seem to have any effect. Currently when the user clicks the combo box all the drop down items font color will be WHITE which is correct. Also do you know how to set tip for each highlight item (some item's wording maybe too long). Oct 23, 2022 · Continue to help good content that is interesting, well-researched, and useful, rise to the top! To gain full voting privileges, We would like to show you a description here but the site won’t allow us. My understanding is the whole thing is the QComboBox widget, and the drop down part is a QLis Dec 7, 2011 · Is it possible to set selected item style (Qt style sheet) of the QComboBox drop-down list? May 27, 2025 · You're telling your program, "Hey, I want to create a new dropdown menu, and I'm going to refer to it as myComboBox. I tried it with the following qss: QComboBox#librarySettingsBox QListView { font-style: normal; /* background-color: rgb (255, 255, 127);*/ } QComboBox { Dec 2, 2020 · I have QComboBox: Screenshot_1. Kind regards Sep 24, 2014 · Depending on some dynamic property, I'd like to set the font style in the top-item of a QComboBox to italic, but keep the appearance of the items in the corresponding popup (QListView). Below is the representation of normal combo box and colorful combo box. Dec 2, 2019 · there is a question disturbing me, maybe it's just a simple question for you guys. PySide6. However, I would prefer the color to cover the whole width of the combobox and only a small part of it. I want that text to be RED, yeah I mean font. This constructor then goes to work behind the scenes to: Create the basic structure of the dropdown menu. e blue th Oct 8, 2017 · I am having trouble changing the highlight colour of a QCombobox in PyQt. A QComboBox provides a means of presenting a list of options to the user in a way that takes up the minimum amount of screen space. May 27, 2025 · Common Errors and Issues No Items in the Combo Box The most common reason is that you haven't added any items to the QComboBox yet. However, when I hover over the QComboBox with my mouse the highlight follows the mouse hover and no longer has the previously selected item highlighted. 8, Qt Designer I'm struggling to set the padding of the text items on a combobox drop down. Learn how to implement, customize, and manage drop-down selection lists effectively for a seamless user experience. So I tried to use StyleSheet with background-color and the QPalette way. Thanks! Sep 5, 2021 · Add QComboBox widgets to your PyQt/PySide projects. setColor (QPalette::Text, condition ? Qt::black : Qt::red); combo->setPalette (palette); @ This worked but my application uses style sheets Apr 20, 2007 · Hi guys, I have a comboBox that displays colors with the last item that displays “other†. QComboBox{ color: rgb(110,209,255); } QComboBox:items{ color: rgb(110,209,255); } QListView{ color: rgb(110,209,255);; } Try adding the QListView css May 27, 2025 · This is where item delegates come into play. Now: It is Dropdown List, the color inside comboBox turns to grey. The way selections are drawn by the delegate, and it is there that it is decided how to draw the selected item. It allows users to choose a single item from a list of options by clicking on the drop-down arrow and selecting an item from the list. Nov 11, 2019 · Pablo J. As is now, the combo box when closed shows the text but not the color. Thanks Oct 19, 2018 · Is it possible, using stylesheets, to change the appearence of the text contained in a selected item such as a QComboBox or a QListWidget? I've tried with a QListWidget but I can change everything except for the text properties. Oct 10, 2017 · How to style a disabled item in a QComboBox ? (qss) Unsolved General and Desktop 3 Posts 3 Posters 3. Jul 19, 2016 · Re: Qt5/C++ - QComboBox - change currrent text color and the dropdown text colour The last two are obviously exclusive, since the stylesheet in line 5 overwrites the one set in line 4. Mar 12, 2024 · For example - I click on the combox, I hover my cursor over "Item 2" and I can apply animation of color change transition to it (which is not possible through stylesheets). Learn how to use them in your apps. Thanks I' already changed the color of the items I put in my combobox the thing is when the list is not opened , I cannot see the item selected because it won't change color. Is there a facility to do this in Qt that I am missing? Mar 12, 2011 · Hi, I'm trying to set my own colors to a QCombobox (ignoring any style) using style sheets in Qt-Designer: background-color: rgb (0, 0, 0); selection-color: rgb (0, 0, 0); selection-background-color: rgb (239, 159, 31); color: rgb (239, 159, 31); in Qt-Designer gives me an orange text on black if I select an QComboBox item (Yeah!). When I first open it, the first item has a light blue color. when the item selected is the blank/ How to change the background color of individual items in the ComboBox or DropDownList dropdown? I would also like to display the item's color in the component itself when that item is selected. Dec 27, 2023 · Are your PyQT app‘s user interfaces starting to feel cluttered? Do radio groups and long lists make it hard to parse options? Well, my friend, it may be time to level up with QComboBox! In this epic tutorial, we‘ll explore how QComboBox can save space and boost usability. I want to change the color and the text of items displayed by a QComboBox, depending on some conditions, but without changing the data in the model itself. We will now see a few examples to get started with using Qt Style Sheets. An item delegate is like a little artist or renderer that takes responsibility for drawing each individual item in your combo box. Comboboxes can contain pixmaps as well as strings; the insertItem() and Apr 2, 2020 · In this article we will see how we can set the background color to the combo box when it get pressed. But once they select the item they want, the drop down will dissapear and the item will be in the combobox but it will be black. See full list on doc. Each item on the menu (the items in the dropdown) has a description and a price. When the user selects an item in a QComboBox it is not displayed as long as the QComboBox has not lost focus. Standard "public" item views (QListView, QTableView, QTreeView and their higher level classes) use QStyledItemDelegate, which, as May 10, 2020 · In this article we will see how we can change the border style of the combo box, border style can be dotted, dashed etc. QComboBox provides a means of presenting a list of options to the user in a way that takes up the minimum amount of screen space. " The new QComboBox () part is actually calling the QComboBox::QComboBox () constructor. If the combo box has even one item, it will likely be selected by default (depending on your setup), and the placeholder won't be visible. I‘ll show you how these versatile dropdown […] Jul 9, 2020 · Hello, I would like something like that: When I add next item to QComboBox, I would like to set its background color ( don't change that later ). Nov 11, 2019 · @qt-1234 said in Change QComboBox popup highlighted item background color: I have a solution to this. Is this possible? Is there a way I could increase the height of the items, which are listed in a QComboBox control ? I tried following as suggested here in QTDevNet forums but with no luck QComboBox QAbstractItemV Jul 9, 2020 · @TomNow99 You mean the item when dropbox is not open? Its a lineEdit, so might need some fiddling. 4k Views 1 Watching Oldest to Newest Oct 21, 2010 · Is there a way to set a different background color for each item in a QComboBox ? Aug 24, 2023 · PyQt QComboBox QComboBox is a widget which provides a list of options to the user in a way that takes up the minimum amount of screen space. It should be RED and it is white. Think of it as adding another option that the user can select. A combobox is a selection widget that displays the current item. I originally tried adding: QComboBox QAbstractItemView { selection-background-color: white; } However, this did not work. How can I change the color of the combo box header ? Oct 16, 2019 · @ JonB said in QCombo selected item background colour: @ Bill52 So how do you set the background color of an item? You need to do the same when an item is selected. Create a combo box 2. setStyleSheet('background-color: rgb(205,92,92)') This adds background to the entire combobox. check doc) to get ModelIndex and read the color with Data function May 27, 2025 · QComboBox::itemDelegate () is a function that allows you to get a pointer to the item delegate that is currently being used by the QComboBox to manage the appearance and editing behavior of its items. Apr 2, 2020 · If editable then set background color else, remove the background color and the other easy way is with the help of style sheet. Jan 11, 2024 · I have a QComboBox with no preselected item. Solution It is possible to apply a custom background color to each item inside the ComboBox/DropDownList dropdown. ComboBox->setStylesheet ("QComboBox { selection-background-color: rgb (0,255,0); }"); or i have to use item delegate in this case? Nov 11, 2019 · Pablo J. 1. By default combo box is of grey color although we can change its color. In this example the choosen item text is "one" ( I think about that "one" above beacuse there are 2 x "one" ). By default, when using Qt Style Sheets, a widget does not automatically inherit its font and color setting from its parent widget. Thanks Oct 26, 2013 · If the user clicked on one of the buttons the new font is handed over to the text item and the focus is going back to it, which is working great. Apr 8, 2023 · width: 36px; height: 36px; background-color: red; } Thats how it looks like with the above spectified code: And thats how it should look like: With QComboBox::drop-down:button its working but I need to style the disabled state also and QComboBox::drop-down:button:disabled wont work. Nov 23, 2018 · For example for string "Elon Musk": "Elon" text color is red; "Musk" text color is green; Thanks in advance for any help you can provide Nov 11, 2019 · Pablo J. When I show the list, only the selected item is visible all other content is white. You can use const QModelIndex idx = colorComboBox->model ()->index (index,0); (or reverse. any tip is appreciated. rukqe ewcbzm gefac ealrpb pzrw uut xrzl rcllo hqv sxtzdt