Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Remove semi-transparent background and border from items in QComboBox / QAbstractItemView

Remove semi-transparent background and border from items in QComboBox / QAbstractItemView

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 1 Posters 560 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Thyringer
    wrote on last edited by
    #1

    How do I remove this predefined semi-transparent background and border from items in QComboBox / QAbstractItemView? The whole thing is particularly noticeable since I added a little more space (padding) on the left and right. I've already tried overriding all properties; but only found out that I can change the color with "selection-background-color", but not remove the transparency.
    Ultimately, I just want a flat design.

    Screenshot_20220415_232611.png
    Screenshot_20220415_232717.png

    For easier understanding, here is the code (inside a Python format string):

    	QComboBox {{
    		background-color: #FFF;
    		border: none;
    		color:#3C3C3C;
    		font-size: {design.font_size};
    		height: {design.width}px;
    		padding: 0 {design.padding}px;
    	}}
    	
    	QComboBox:editable {{
    		background: #FFF;
    	}}
    
    	QComboBox QAbstractItemView {{
    		border: 1px solid {ac};
    		font-size: {design.notepad_font_size};
    	}}
    	
    	QComboBox QAbstractItemView::item {{
    		border: none;
    		color: #3C3C3C;
    		height: {design.width}px;
    		padding: 0 {design.padding}px;
    		selection-background-color: #F29100;
    	}}
    	
    	QComboBox QAbstractItemView::item:hover, QComboBox QAbstractItemView::item:selected {{
    		background-color: #F29100;
    		border: none;
    		selection-color: #FFF;
    	}}
    
    1 Reply Last reply
    0
    • T Offline
      T Offline
      Thyringer
      wrote on last edited by
      #2

      I have the same problem with the QListWidget, but I was able to switch off this annoying background by specifying setFocusPolicy(Qt.NoFocus). Unfortunately, this doesn't work with my drop-down list:

      def DropDownList(*items: str) -> QComboBox:
      	list = QDropDownList(*items)
      	list.setFocusPolicy(Qt.NoFocus)
      	view = list.view()
      	view.setEditTriggers(QAbstractItemView.NoEditTriggers)
      	view.setFocusPolicy(Qt.NoFocus)
      	return list
      
      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved