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. How to keep background-color of QTavbeView when it lose the focus?

How to keep background-color of QTavbeView when it lose the focus?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 576 Views 1 Watching
  • 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.
  • qazaq408Q Offline
    qazaq408Q Offline
    qazaq408
    wrote on last edited by
    #1

    For instance,i click a row of QTableView,and the background-color of this row change to blue;

    And then,i click the button "Find" to lanuch a dialog,QTabelView lose the focus,and the background-color of row that's checked is change to white.

    How to keep background-color of QTavbeView when it lose the focus?

    I try to use QSS,but it doesn't work

    QString tableviewStyleStr = "QTableView::item:selected {background - color: #1E90FF; color: white;} ";
    tableviewStyleStr += "QTableView::item:selected:!active{background - color: #1E90FF; color: white;} ";
    tableview_student->setStyleSheet(tableviewStyleStr);
    

    BG1.png

    BG2.png

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You can alter the palette of your QTableView to modify the colors in the inactive state.

      This StackOverflow answer shows it.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • qazaq408Q qazaq408 has marked this topic as solved on

      • Login

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