Results 1 to 2 of 2

Thread: error in QtreeView Stylesheet

  1. #1
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default error in QtreeView Stylesheet

    Qt Code:
    1. QTreeView *asrtTView = new QTreeView();
    2.  
    3. QVBoxLayout *layout = new QVBoxLayout;
    4. layout->addWidget(asrtTView);
    5. QList<QStandardItem *> items,items2;
    6. assortModel= new QStandardItemModel;
    7.  
    8. QStandardItem *wit1 = new QStandardItem("Peter");
    9. QStandardItem *wit2 = new QStandardItem("Family");
    10. QStandardItem *wit3 = new QStandardItem("Paul");
    11. QStandardItem *wit4 = new QStandardItem("John");
    12. QStandardItem *wit5 = new QStandardItem("Jack");
    13. QStandardItem *wit6 = new QStandardItem("Amie");
    14.  
    15. assortModel->invisibleRootItem()->appendRow(wit1);
    16. assortModel->invisibleRootItem()->appendRow(wit2);
    17. assortModel->invisibleRootItem()->appendRow(wit3);
    18. assortModel->invisibleRootItem()->appendRow(wit4);
    19. assortModel->invisibleRootItem()->appendRow(wit5);
    20. assortModel->invisibleRootItem()->appendRow(wit6);
    21.  
    22. assortModel->setHorizontalHeaderLabels( QStringList() << "2 Wits" <<"Assorted" );
    23. asrtTView->setModel(assortModel);
    24. asrtTView->expandAll();
    25. asrtTView->model()->setData(asrtTView->model()->index(0,1),QVariant("first 1 costs wariant"));
    26. asrtTView->model()->setData(asrtTView->model()->index(0,1).child(0,0),QVariant ("testing if i can change it like that"));
    27.  
    28.  
    29.  
    30. ui->dropFrame->setLayout(layout);
    31. asrtTView->setStyleSheet(" alternate-background-color: yellow;show-decoration-selected: 1;");
    32. // asrtTView->setStyleSheet(QTreeView::item {border: 1px solid #d9d9d9; border-top-color: transparent;border-bottom-color: transparent; });//this line shows error
    To copy to clipboard, switch view to plain text mode 


    I want to use item:hover, item:selected and all. How can I use this?
    Last edited by vinayaka; 1st March 2012 at 07:23.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: error in QtreeView Stylesheet

    Your line won't compile because you are missing quotes around the string literal.

Similar Threads

  1. Replies: 7
    Last Post: 7th December 2010, 04:36
  2. QTreeView::item stylesheet
    By Baasie in forum Qt Programming
    Replies: 1
    Last Post: 15th December 2009, 14:55
  3. How to set StyleSheet for checkbox in QTreeView;
    By visor_ua in forum Qt Programming
    Replies: 3
    Last Post: 7th April 2009, 11:46
  4. QTreeView rows (items) StyleSheet
    By Kostanev in forum Qt Programming
    Replies: 1
    Last Post: 15th September 2007, 10:36
  5. QTreeView HeaderData StyleSheet
    By Kostanev in forum Qt Programming
    Replies: 2
    Last Post: 12th September 2007, 22:12

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.