<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
That's because the following constructor is being used when you call
QTreeWidgetItem(hdr, x):<br>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<span class="Apple-style-span"
style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Arial; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><b><br>
</b></span>QTreeWidgetItem ( QTreeWidgetItem * parent, const
QStringList & strings, int type = Type )<br>
<br>
so it is treating your string as a list of strings. Since your column
count is 1, you are only seeing the first character. You need to change
your code as follows:<br>
<br>
QTreeWidgetItem(hdr, [x])<br>
<br>
-Selim<br>
<br>
Jason Rahm wrote:
<blockquote
cite="mid:B6CD82222C044C49BC851157ABB8637E60633874@SEAEMBX01.olympus.F5Net.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; ">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">Here’s my code:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> selected = None<o:p></o:p></p>
<p class="MsoNormal"> self.treeWidget_iRulesList.clear()<o:p></o:p></p>
<p class="MsoNormal">
self.treeWidget_iRulesList.setColumnCount(1)<o:p></o:p></p>
<p class="MsoNormal">
self.treeWidget_iRulesList.setHeaderLabels(["Rules"])<o:p></o:p></p>
<p class="MsoNormal">
self.treeWidget_iRulesList.setItemsExpandable(True)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> for item in allrules.keys():<o:p></o:p></p>
<p class="MsoNormal"> #print item<o:p></o:p></p>
<p class="MsoNormal"> hdr = QTreeWidgetItem(item)<o:p></o:p></p>
<p class="MsoNormal">
self.treeWidget_iRulesList.addTopLevelItem(hdr)<o:p></o:p></p>
<p class="MsoNormal">
self.treeWidget_iRulesList.expandItem(hdr)<o:p></o:p></p>
<p class="MsoNormal"> for x in allrules[item]:<o:p></o:p></p>
<p class="MsoNormal"> #print x<o:p></o:p></p>
<p class="MsoNormal"> rule = QTreeWidgetItem(hdr,
x)<o:p></o:p></p>
<p class="MsoNormal">
self.treeWidget_iRulesList.addTopLevelItem(rule)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">If I uncomment my print statements, each string
is printed as expected, but in the QTreeWidget, I only get the first
character:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">-g<o:p></o:p></p>
<p class="MsoNormal">----g<o:p></o:p></p>
<p class="MsoNormal">----t<o:p></o:p></p>
<p class="MsoNormal">----t<o:p></o:p></p>
<p class="MsoNormal">-l<o:p></o:p></p>
<p class="MsoNormal">----h<o:p></o:p></p>
<p class="MsoNormal">----u<o:p></o:p></p>
<p class="MsoNormal">----_<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">And so on. Any ideas? Thanks in advance.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Jason<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<pre wrap="">
<hr size="4" width="90%">
_______________________________________________
PyQt mailing list <a class="moz-txt-link-abbreviated" href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a>
<a class="moz-txt-link-freetext" href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a></pre>
</blockquote>
</body>
</html>