Results 1 to 5 of 5

Thread: Q3ListViewItem background color

  1. #1
    Join Date
    Feb 2006
    Posts
    60
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    21

    Default Q3ListViewItem background color

    hi,
    I want to set the background color to Q3ListViewItem. I am using QT4.1.

    Thanks in advance,

    bye.
    sree

  2. #2
    Join Date
    Jan 2006
    Location
    N.B. Canada
    Posts
    47
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanked 8 Times in 7 Posts

    Default Re: Q3ListViewItem background color

    I think you have to get the Q3ListView palette; and then use setBrush() with QPalette::Background color role to set the palette's background colour, and then set the Q3ListView's palette to the modified palette. You can also change the alternating row with the QPalette::AlternateBase colour role.

    Bojan
    The march of progress:
    C:
    printf("%10.2f", x);
    C++:
    cout << setw(10) << setprecision(2) << showpoint << x;
    Java:
    java.text.NumberFormat formatter = java.text.NumberFormat.getNumberInstance();
    formatter.setMinimumFractionDigits(2);
    formatter.setMaximumFractionDigits(2);
    String s = formatter.format(x);
    for (int i = s.length(); i < 10; i++) System.out.print(' ');
    System.out.print(s);

  3. #3
    Join Date
    Feb 2006
    Posts
    60
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    21

    Default Re: Q3ListViewItem background color

    Thanks for the reply,
    In my Q3ListView I have Q3ListViewItems which depends on other Q3ListViewItems. And if i Selecet any one of them i want to set the background of all the dependents to gray

    bye,
    sreedhar

  4. #4
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows
    Thanks
    9
    Thanked 27 Times in 27 Posts

    Default Re: Q3ListViewItem background color

    And if i understand you cant change item colors?
    I think you must subclass QListViewItem and play with reimplementing paintBrushes() or paintCell()
    a life without programming is like an empty bottle

  5. #5
    Join Date
    Feb 2006
    Posts
    60
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    21

    Default Re: Q3ListViewItem background color

    Thanks for the reply,

    I reimplemented paintcell as shown below and it works fine

    void QCexItem:aintCell( QPainter * p, const QColorGroup &cg,
    int column, int width, int align)
    {
    const QBrush brush(Qt::lightgray);
    p->fillRect(0,0, width, height(), brush);
    Q3ListViewItem:aintCell( p, cg, column, width, align );
    return;
    }

    but if i want to change the color of the text in the Q3ListVuewItem, i cannot do it ,

    If you have any suggestions please do reply,

    bye,
    sree

Similar Threads

  1. button background color when it is clicked
    By navi1084 in forum Qt Programming
    Replies: 5
    Last Post: 24th June 2024, 13:09
  2. Change QPushButton Background Color, Qt4.3
    By Rayven in forum Qt Programming
    Replies: 5
    Last Post: 4th July 2009, 08:14
  3. how to change QTextEdit background color ?
    By mismael85 in forum Qt Programming
    Replies: 9
    Last Post: 26th June 2008, 23:05
  4. Menu bar background color focus
    By user_mail07 in forum Qt Tools
    Replies: 0
    Last Post: 18th May 2007, 02:25
  5. QLabel background color
    By munna in forum Newbie
    Replies: 3
    Last Post: 1st May 2006, 16:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.