Results 1 to 6 of 6

Thread: QListView StyleSheet NOT WORKING!

  1. #1
    Join Date
    Jul 2008
    Posts
    139
    Thanks
    9
    Thanked 18 Times in 15 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default QListView StyleSheet NOT WORKING!

    hi, ok it seems Trolltech wants me to become a rocket scientist, I can't figure out why this stylesheet will not work. The only part of it working is show-decoration-selected: 1;
    This is the example right out of the docs, I want to make it work before I put my style in. ( change font, and color).
    I have QtEmbedded 4.4.1
    Thanks for any tips.

    Qt Code:
    1. ui->listWidget->setStyleSheet("QListView { show-decoration-selected: 1;}\
    2. item:alternate { background: #EEEEEE;}\
    3. item:selected:active{ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ADAFE5, stop: #8588B2);}\
    4. item:selected:!active{ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #6a6ea9, stop: #888dd9);}");
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images

  2. #2
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QListView StyleSheet NOT WORKING!

    Nice-looking GUI.

    I looked through some old code where I styled a QListWidget and my code looked similar to yours except that I called the items with class scope (i.e. QListWidget::item:alternate), so maybe it's that. I've never worked with Qt embedded though.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QListView StyleSheet NOT WORKING!

    Do you use a custom delegate? If so, what did you derive it from?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Jul 2008
    Posts
    139
    Thanks
    9
    Thanked 18 Times in 15 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QListView StyleSheet NOT WORKING!

    Hi.
    No I am not using a custom delegate. For the list items I am using the text name and an icon with it. Created it using the designer. All I would like to do is change the font to bold when the item is selected.

  5. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QListView StyleSheet NOT WORKING!

    Hi, the qlineargradient () syntax is wrong. You have forgotten a number for the last stop.

  6. The following user says thank you to Lykurg for this useful post:

    QbelcorT (22nd March 2009)

  7. #6
    Join Date
    Jul 2008
    Posts
    139
    Thanks
    9
    Thanked 18 Times in 15 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Lightbulb Re: QListView StyleSheet NOT WORKING!

    my bad, thanks Lykurg, I forgot the last stops. I think I'll leave the selection color in for the rectangle, it looks better than bolding the text.

    Qt Code:
    1. #define LISTVIEWSTYLE "QListView { show-decoration-selected: 1;}\
    2. QListView::item:alternate { background: transparent;}\
    3. QListView::item:selected:active{ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ADAFE5, stop: 1 #8588B2);}\
    4. QListView::item:selected:!active{ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #6a6ea9, stop: 1 #888dd9);}"
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images

Similar Threads

  1. GUI thread and Working thread comunication
    By FasTTo in forum Qt Programming
    Replies: 2
    Last Post: 13th September 2007, 15:31
  2. QListView word wrap
    By serega in forum Qt Programming
    Replies: 17
    Last Post: 30th August 2007, 03:13
  3. QDialog / QListView problem
    By harakiri in forum Qt Programming
    Replies: 1
    Last Post: 10th July 2007, 18:31
  4. Subclass QListView to show two colums in one
    By Mookie in forum Qt Programming
    Replies: 2
    Last Post: 23rd June 2007, 02:12
  5. Keeping focus at bottom of QListView
    By jakamph in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2006, 14:45

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.