<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How can I set round corners to QListVIew items?]]></title><description><![CDATA[<p dir="auto">Hello all!</p>
<p dir="auto">I have the QListView with items. when I select the item the item gets highlighted but it has ordinary corners, I want to round the corners how can I so it?</p>
<p dir="auto">thank you again!</p>
]]></description><link>https://forum.qt.io/topic/50650/how-can-i-set-round-corners-to-qlistview-items</link><generator>RSS for Node</generator><lastBuildDate>Wed, 18 Nov 2026 14:04:53 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/50650.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 28 Jan 2015 15:33:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How can I set round corners to QListVIew items? on Thu, 29 Jan 2015 09:57:01 GMT]]></title><description><![CDATA[<p dir="auto">Ok, I did it, thank you!! :)</p>
]]></description><link>https://forum.qt.io/post/259687</link><guid isPermaLink="true">https://forum.qt.io/post/259687</guid><dc:creator><![CDATA[tokafr]]></dc:creator><pubDate>Thu, 29 Jan 2015 09:57:01 GMT</pubDate></item><item><title><![CDATA[Reply to How can I set round corners to QListVIew items? on Thu, 29 Jan 2015 07:39:27 GMT]]></title><description><![CDATA[<p dir="auto">Well you never said anything about it. Don't you think this would have been of any interest from the beginning?!!</p>
<p dir="auto">drawRoundRect() is not a method of QPainter?!</p>
<p dir="auto">"drawRoundedRect()":<a href="http://doc.qt.io/qt-5/qpainter.html#drawRoundedRect" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.io/qt-5/qpainter.html#drawRoundedRect</a> is and also has parameters to specify the border radius.</p>
]]></description><link>https://forum.qt.io/post/259649</link><guid isPermaLink="true">https://forum.qt.io/post/259649</guid><dc:creator><![CDATA[raven-worx]]></dc:creator><pubDate>Thu, 29 Jan 2015 07:39:27 GMT</pubDate></item><item><title><![CDATA[Reply to How can I set round corners to QListVIew items? on Thu, 29 Jan 2015 07:29:34 GMT]]></title><description><![CDATA[<p dir="auto">yes I paint the items, how can I paint rounded border when (the rect there is option.rect) and then fill the rounded border?<br />
@<br />
painter-&gt;drawRoundRect(option.rect);<br />
painter-&gt;fillRect(option.rect, option.palette.highlight());<br />
@</p>
<p dir="auto">fills the default rectangle without rounded borders</p>
]]></description><link>https://forum.qt.io/post/259644</link><guid isPermaLink="true">https://forum.qt.io/post/259644</guid><dc:creator><![CDATA[tokafr]]></dc:creator><pubDate>Thu, 29 Jan 2015 07:29:34 GMT</pubDate></item><item><title><![CDATA[Reply to How can I set round corners to QListVIew items? on Thu, 29 Jan 2015 07:20:24 GMT]]></title><description><![CDATA[<p dir="auto">@listWidget-&gt;setItemDelegate(delegate);@<br />
Whats the type of the delegate and what it's purpose?</p>
<p dir="auto">Make sure it's of the type QStyledItemDelegate and of course don't override it's paint method. If you have to override the paint() method you also need to make sure that you paint the rounded border.</p>
]]></description><link>https://forum.qt.io/post/259643</link><guid isPermaLink="true">https://forum.qt.io/post/259643</guid><dc:creator><![CDATA[raven-worx]]></dc:creator><pubDate>Thu, 29 Jan 2015 07:20:24 GMT</pubDate></item><item><title><![CDATA[Reply to How can I set round corners to QListVIew items? on Thu, 29 Jan 2015 06:54:33 GMT]]></title><description><![CDATA[<p dir="auto">@<br />
listWidget = new QListView(this);</p>
<pre><code>listWidget-&gt;setSelectionBehavior(QListView::SelectRows);
listWidget-&gt;setEditTriggers(QListView::AllEditTriggers);


/* here we set the initial data by hand. */

Connection conn1("toka","cloud","http","linux","192.168.1.108");
Connection conn2(QObject::tr("localhost"),QObject::tr("Server"),QObject::tr("ssh"),
                     QObject::tr("windows"),QObject::tr("192.168.1.254"),QPixmap(":/icons/images.png"));

model-&gt;addRow(conn1);
model-&gt;addRow(conn2);
proxy-&gt;setSourceModel(model);
listWidget-&gt;setModel(proxy);
listWidget-&gt;setStyleSheet(
      "QListView::item:selected {"
      "border: 1px solid black;"
      "border-radius: 3px;"
      "color: black;"
      "}"
      );
listWidget-&gt;setItemDelegate(delegate);
</code></pre>
<p dir="auto">@</p>
]]></description><link>https://forum.qt.io/post/259640</link><guid isPermaLink="true">https://forum.qt.io/post/259640</guid><dc:creator><![CDATA[tokafr]]></dc:creator><pubDate>Thu, 29 Jan 2015 06:54:33 GMT</pubDate></item><item><title><![CDATA[Reply to How can I set round corners to QListVIew items? on Wed, 28 Jan 2015 21:45:19 GMT]]></title><description><![CDATA[<p dir="auto">[quote author="tokafr" date="1422478813"]* raven-worx*<br />
there you have QListWidget, Does it work for QListView also because here with me it doesn't do that [/quote]</p>
<p dir="auto">QListWidget derives from QListView, so yes it does work also with it.<br />
To be more specific the <em>item</em> selector works for almost all QAbstractItemView widgets.</p>
<p dir="auto">Then post some code, maybe we can spot something.</p>
]]></description><link>https://forum.qt.io/post/259590</link><guid isPermaLink="true">https://forum.qt.io/post/259590</guid><dc:creator><![CDATA[raven-worx]]></dc:creator><pubDate>Wed, 28 Jan 2015 21:45:19 GMT</pubDate></item><item><title><![CDATA[Reply to How can I set round corners to QListVIew items? on Wed, 28 Jan 2015 21:00:13 GMT]]></title><description><![CDATA[<ul>
<li>raven-worx*<br />
there you have QListWidget, Does it work for QListView also because here with me it doesn't do that</li>
</ul>
]]></description><link>https://forum.qt.io/post/259586</link><guid isPermaLink="true">https://forum.qt.io/post/259586</guid><dc:creator><![CDATA[tokafr]]></dc:creator><pubDate>Wed, 28 Jan 2015 21:00:13 GMT</pubDate></item><item><title><![CDATA[Reply to How can I set round corners to QListVIew items? on Wed, 28 Jan 2015 20:58:03 GMT]]></title><description><![CDATA[<p dir="auto">Check your syntax again.  It works for me<br />
@MainWindow::MainWindow(QWidget *parent)<br />
: QMainWindow(parent)<br />
{<br />
lv = new QListView(this);<br />
QStandardItemModel *model = new QStandardItemModel(this);<br />
QStringList headers;<br />
model-&gt;setHorizontalHeaderLabels(headers);<br />
model-&gt;setRowCount(3);<br />
QStandardItem *one = new QStandardItem("ONE");<br />
QStandardItem *two = new QStandardItem("TWO");<br />
QStandardItem *three = new QStandardItem("THREE");</p>
<pre><code>model-&gt;setItem(0,one);
model-&gt;setItem(1,two);
model-&gt;setItem(2,three);


lv-&gt;setStyleSheet("QListView::item:selected {background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #004400, stop: 1 #00ff00); border: 1px solid #990033; border-radius: 6px;}");

lv-&gt;setModel(model);
setCentralWidget(lv);
</code></pre>
<p dir="auto">}@</p>
]]></description><link>https://forum.qt.io/post/259585</link><guid isPermaLink="true">https://forum.qt.io/post/259585</guid><dc:creator><![CDATA[DBoosalis]]></dc:creator><pubDate>Wed, 28 Jan 2015 20:58:03 GMT</pubDate></item><item><title><![CDATA[Reply to How can I set round corners to QListVIew items? on Wed, 28 Jan 2015 20:47:44 GMT]]></title><description><![CDATA[<p dir="auto">just tested...works for me.</p>
<p dir="auto">!<a href="http://oi62.tinypic.com/2gtp1yu.jpg(screenshot)" target="_blank" rel="noopener noreferrer nofollow ugc">http://oi62.tinypic.com/2gtp1yu.jpg(screenshot)</a>!</p>
<p dir="auto">@<br />
QListWidget l;<br />
l.addItems( QStringList() &lt;&lt; "111" &lt;&lt; "222" &lt;&lt; "333" );<br />
l.setStyleSheet(<br />
"QListView::item:selected {"<br />
"border: 1px solid #6a6ea9;"<br />
"border-radius: 5px;"<br />
"color: black;"<br />
"}"<br />
);<br />
l.show();<br />
@</p>
]]></description><link>https://forum.qt.io/post/259583</link><guid isPermaLink="true">https://forum.qt.io/post/259583</guid><dc:creator><![CDATA[raven-worx]]></dc:creator><pubDate>Wed, 28 Jan 2015 20:47:44 GMT</pubDate></item><item><title><![CDATA[Reply to How can I set round corners to QListVIew items? on Wed, 28 Jan 2015 20:17:47 GMT]]></title><description><![CDATA[<p dir="auto">doesn't do anything :(</p>
]]></description><link>https://forum.qt.io/post/259580</link><guid isPermaLink="true">https://forum.qt.io/post/259580</guid><dc:creator><![CDATA[tokafr]]></dc:creator><pubDate>Wed, 28 Jan 2015 20:17:47 GMT</pubDate></item><item><title><![CDATA[Reply to How can I set round corners to QListVIew items? on Wed, 28 Jan 2015 15:44:06 GMT]]></title><description><![CDATA[<p dir="auto">use stylesheets or a custom item delegate and override it's paint method.</p>
<p dir="auto">Example stylesheet (untested):<br />
@<br />
listView-&gt;setStyleSheet(<br />
"QListView::item:selected {"<br />
"border: 1px solid #6a6ea9;"<br />
"border-radius: 3px;"<br />
"}"<br />
);<br />
@</p>
]]></description><link>https://forum.qt.io/post/259558</link><guid isPermaLink="true">https://forum.qt.io/post/259558</guid><dc:creator><![CDATA[raven-worx]]></dc:creator><pubDate>Wed, 28 Jan 2015 15:44:06 GMT</pubDate></item></channel></rss>