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. QListWidget IconMode ,set selected style

QListWidget IconMode ,set selected style

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 359 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.
  • W Offline
    W Offline
    wuj10n
    wrote on last edited by
    #1

    屏幕截图 2023-03-10 123031.png
    This is the screenshot when selecting Item3.

    屏幕截图 2023-03-10 123345.png
    This is the screenshot after selecting Item 3 and clicking the blank part of the QListWidget window.The text part of Item3 now has dotted border.

    My question is how to change the item style in the second screenshot to make it consistent with the item style in the first screenshot .

    #mystyle.qss
    QListWidget::item:selected {
        background-color: transparent;
        color: red;
        border: 3px solid red;
    }
    
    QListWidget::item {
        margin:10px;
        border: 1px solid black;
    }
    
    EmrecpE 1 Reply Last reply
    0
    • W wuj10n

      屏幕截图 2023-03-10 123031.png
      This is the screenshot when selecting Item3.

      屏幕截图 2023-03-10 123345.png
      This is the screenshot after selecting Item 3 and clicking the blank part of the QListWidget window.The text part of Item3 now has dotted border.

      My question is how to change the item style in the second screenshot to make it consistent with the item style in the first screenshot .

      #mystyle.qss
      QListWidget::item:selected {
          background-color: transparent;
          color: red;
          border: 3px solid red;
      }
      
      QListWidget::item {
          margin:10px;
          border: 1px solid black;
      }
      
      EmrecpE Offline
      EmrecpE Offline
      Emrecp
      wrote on last edited by
      #2

      @wuj10n When adding QListWidgetItem to QListWidget,
      update QListWidgetItem flag like this

      listeWidgetItem.setFlags(listWidgetItem.flags() & (~Qt.ItemIsSelectable))
      
      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