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. Qt background color of row in ListStringModel
Qt 6.11 is out! See what's new in the release blog

Qt background color of row in ListStringModel

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

    i try set color of row with this code and it doesnt work.

    @ QColor dataColor =Qt::red;
    row = seznamChyb->rowCount();
    seznamChyb->insertRows(row,1);

    QModelIndex index = seznamChyb->index(row);
    ui->listView->setCurrentIndex(index);
    
    seznamChyb->setData(index,dataColor, Qt::BackgroundRole);
    seznamChyb->setData(index,data);@
    
    1 Reply Last reply
    0
    • IamSumitI Offline
      IamSumitI Offline
      IamSumit
      wrote on last edited by
      #2

      Hi .
      in line 8.
      this is wrong setData() function parameter supplied wrong.

      "Qt docs":http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#setData
      so it will not work.

      hope this help.

      Be Cute

      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