Results 1 to 3 of 3

Thread: QTreeView branch images won't show up

  1. #1
    Join Date
    Apr 2014
    Posts
    53
    Thanks
    9

    Default QTreeView branch images won't show up

    Hi,
    I am trying to setup a tree visualization like in this picture (with "+" and "-" signs):
    http://qt.developpez.com/doc/4.6/ima...el-example.png
    but I only see the default setup with triangles.
    I have checked the stylesheet reference , downloaded and put the vline.png and branch-more.png from the internet and put it into the build directory , also just in case copied to source directory, and also added as resource. But the images won't show up.
    The code to set the stylesheet of the QTreeView is this:

    Qt Code:
    1. deptree=new QTreeWidget();
    2. deptree->setColumnCount(2);
    3. deptree->setStyleSheet("QTreeView::branch:has-siblings:!adjoins-item { border-image: url(:/images/deptrack_images/vline.png) 0; }");
    4. deptree->setStyleSheet("QTreeView::branch:has-siblings:adjoins-item { border-image: url(:/images/deptrack_images/branch-more.png) 0;}");
    5. deptree->setStyleSheet("QTreeView::branch:!has-children:!has-siblings:adjoins-item { border-image: url(branch-end.png) 0;}");
    6. deptree->setStyleSheet("QTreeView::branch:has-children:!has-siblings:closed,");
    7. deptree->setStyleSheet("QTreeView::branch:closed:has-children:has-siblings { border-image: none; image: url(notexistentfile.png); }");
    8. deptree->setStyleSheet("QTreeView::branch:open:has-children:!has-siblings,");
    9. deptree->setStyleSheet("QTreeView::branch:open:has-children:has-siblings { border-image: none; image: url(branch-open.png); }");
    10.  
    11. twi=new QTreeWidgetItem();
    12. twi->setText(0,"uno");
    13. deptree->addTopLevelItem(twi);
    14. ptwi=twi;
    15.  
    16. twi=new QTreeWidgetItem();
    17. twi->setText(0,"subuno");
    18. ptwi->addChild(twi);
    19.  
    20. ptwi=twi;
    21. twi=new QTreeWidgetItem();
    22. twi->setText(0,"subsubuno");
    23. ptwi->addChild(twi);
    24.  
    25. main_layout->addWidget(deptree);
    26. tree_test->setLayout(main_layout);
    27. tree_test->show();
    To copy to clipboard, switch view to plain text mode 

    I think the problem is: QT can't locate the images. How do I know , if the image is opened successfuly by the stylesheet? I have ran the debugger with "Step In" to setStyleSheet() method but it doesn't do anything there, that would look like opening an image, it even doesn't get close to stylesheet code. I also have put wrong image file names on purpose, and it is absolutely ignored, the triangles keep appearing as nothing hapened.

    Is there any example of a table I am trying to do online so I could copy and paste the code?

    TIA

  2. #2
    Join Date
    Apr 2014
    Posts
    53
    Thanks
    9

    Default Re: QTreeView branch images won't show up

    solved it.
    apparently stylesheet text need to have new lines otherwise the QT engine doesn't interpret them

  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: QTreeView branch images won't show up

    setStylesheet overrides the previously set stylesheet so only the last statement you used in your initial post has any effect.
    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.


Similar Threads

  1. QTreeView: shift-click [+] decorator to fully expand branch
    By chezifresh in forum Qt Programming
    Replies: 1
    Last Post: 2nd September 2015, 12:47
  2. QTreeView::branch gridline-color?
    By chouqud in forum Newbie
    Replies: 2
    Last Post: 21st March 2014, 12:48
  3. QTreeView branch indicator bug?
    By ugluk in forum Qt Programming
    Replies: 2
    Last Post: 28th May 2012, 11:55
  4. Replies: 2
    Last Post: 2nd November 2009, 14:24
  5. Looking for a method to show several images
    By harakiri in forum Newbie
    Replies: 3
    Last Post: 26th June 2007, 11:57

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.