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. QTableView header background color for cell ZERO
QtWS25 Last Chance

QTableView header background color for cell ZERO

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

    Hello All,

    I need help regarding QTableView header background color change. I have a QTableView with both vertical and horizontal headers in it. I'm able to change the background color of both header other than one cell. The one cell at intersection of two headers (you may call is cell zero of both vertical and horizontal headers).

    I've following code to change the header color -
    header->setStyleSheet ("QHeaderView { font: bold 12px; font-family: microsoft sans serif; color: #5d6d7e; text-align: top right;}");

    and in model -
    QVariant dataModel::headerData(int section, Qt::Orientation orientation, int role) const
    {
    QVariant header;

     if (role == Qt::BackgroundColorRole)
     {
    	 return Qt::white;
     }
    

    .......
    }

    Please suggest if there is any way to fix this issue.

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      from http://doc.qt.io/qt-4.8/stylesheet-examples.html#customizing-qtableview

      The corner widget can be customized using the following style sheet

      QTableView QTableCornerButton::section {
          background: red;
          border: 2px outset red;
      }
      

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      3

      • Login

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