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. Changing color of listView elements?
Forum Updated to NodeBB v4.3 + New Features

Changing color of listView elements?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 2.4k 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.
  • Q Offline
    Q Offline
    Qnoobish
    wrote on last edited by
    #1

    Hello,

    I would like the possibility to change the color of elements loaded into my ListView through a model.

    I've been trying to to this and all I could do is change the element text to bold or italics using some HTML tags like <b></b> but I haven't been able to change the color at will.

    Any suggestions?

    Thanks in advance :) .

    In short, software is eating the world.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      beemaster
      wrote on last edited by
      #2

      QML ListView?

      1 Reply Last reply
      0
      • L Offline
        L Offline
        leon.anavi
        wrote on last edited by
        #3

        I guess that you are talking about "QListView":http://qt-project.org/doc/qt-4.8/qlistwidget.html because this topic is posted under the General and Desktop forum. Check the "following tutorial about background color of QWidget":http://qt-project.org/wiki/How_to_Change_the_Background_Color_of_QWidget.

        http://anavi.org/

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          The foreground and background colors are provided by your model.
          You should return wanted color in your data(const QModelIndex&, int role) implementation of the model.
          To change text color check role parameter for Qt::ForegroundRole and Qt::BackgroundRole for background.

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            Qnoobish
            wrote on last edited by
            #5

            Oh sorry I forgot to mention that I am using QML ListView

            In short, software is eating the world.

            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