Qtreewidget style settings Daquan (i)

Source: Internet
Author: User
Tags dashed line
When using Qtreewidget, the default is a dashed line, as shown in the following illustration: The Qtreewidget node display now needs to remove the dashed lines between these nodes in two ways, one to add the control's style to the code and the other to set the style directly in the Qtcreator. First: Qtcreator style: Right-click the control, select Change StyleSheet ... menu, and then go to the style editing interface, add the following code: qtreeview::branch {image:none;} style interface Click OK, you can see the effect, the previous dashed line is gone. The second type: Add the style directly in the code: The code is as follows: Treewidget->setstylesheet ("Qtreeview::branch {image:none;}"); The treewidget here refers to the current Qtreewidget object. Paste out the source image: After the code is compiled and run, you can see the effect. Next, to introduce, only set the top-level node no dashed line, child nodes have a dashed line method: The same can be used in the source code set style and Qtcreator style two methods, here will not repeat, set the parameters of a brief introduction. Add the following method to the code: treewidget->setrootisdecorated (FALSE); Qtcreator Click on the Qtreewidget control, in the right setting properties found Qtreeview that column, will rootis decorated check box, do not tick, you can achieve the effect. Finally, set the item to display the background color in different state of the code, set the same way: the source set: Treewidget->setstylesheet ("Qtreeview::item:hover{background-color:rgb (0,255,0,50)} "" Qtreeview::item:selected{background-color:rgb (255,0,0,100)} "); In the style settings interface, add the following two sentences: Qtreeview::item:hover{background-color:rgb (0,255,0,50)} qtreeview::item:selected{ Background-color:rgb (255,0,0,100)}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.