<?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[QTableWidget::setCellWidget() a QLineEdit for very large table?]]></title><description><![CDATA[<p dir="auto">Hi,<br />
I have a QTableWidget in my Main Window. Now I know that we can set item as QTableWidgetItem for each cell.<br />
Instead I wanted to ask what is the effect of adding QLineEdit through setCellWidget() for each cell, rather than QTableWidgetItem through setItem().<br />
I want to know whether there is any impact on speed on my application?<br />
The tablewidget has &gt;10,000 rows &amp; &gt;10,000 columns.<br />
So which one of the 2 mentioned above is better to use for faster &amp; less dynamic memory consuming application?<br />
If I could not make my question clear enough then please feel free to ask for details.<br />
Thank You.</p>
]]></description><link>https://forum.qt.io/topic/25956/qtablewidget-setcellwidget-a-qlineedit-for-very-large-table</link><generator>RSS for Node</generator><lastBuildDate>Sun, 16 Aug 2026 06:52:39 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/25956.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 07 Apr 2013 12:02:24 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QTableWidget::setCellWidget() a QLineEdit for very large table? on Wed, 10 Apr 2013 05:32:35 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I dont think that maintaining a QList&lt;QLineEdit *&gt; is a good idea at all. Since you want to use a QDoubleValidator and other properties I would suggest you to create a class that inherits "QStyledItemDelegate":<a href="http://qt-project.org/doc/qt-5.0/qtwidgets/qstyleditemdelegate.html" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/doc/qt-5.0/qtwidgets/qstyleditemdelegate.html</a> and override the required functions.  In the "createEditor()":<a href="http://qt-project.org/doc/qt-5.0/qtwidgets/qstyleditemdelegate.html#createEditor" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/doc/qt-5.0/qtwidgets/qstyleditemdelegate.html#createEditor</a> function you can create a new lineEdit and specify your properties on that.</p>
<p dir="auto">I would also suggest you to use "model/view architecture":<a href="http://qt-project.org/doc/qt-5.0/qtwidgets/model-view-programming.html" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/doc/qt-5.0/qtwidgets/model-view-programming.html</a> so you can replace QTableWidget to QTableView and use a model that will hold the data.</p>
<p dir="auto">You can have a look at "Star Delegate Example":<a href="http://qt-project.org/doc/qt-4.8/itemviews-stardelegate.html" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/doc/qt-4.8/itemviews-stardelegate.html</a> for reference. Incase you need any help feel free to ask.</p>
]]></description><link>https://forum.qt.io/post/173134</link><guid isPermaLink="true">https://forum.qt.io/post/173134</guid><dc:creator><![CDATA[Sam]]></dc:creator><pubDate>Wed, 10 Apr 2013 05:32:35 GMT</pubDate></item><item><title><![CDATA[Reply to QTableWidget::setCellWidget() a QLineEdit for very large table? on Sun, 07 Apr 2013 12:59:40 GMT]]></title><description><![CDATA[<p dir="auto">Hi Sam,<br />
Actually I had developed my application with individual QLineEdit in the GUI instead of QTableWidget previously. But I observed that the performance heavily dropped down for larger no of rows &amp; columns.<br />
So I decided to use QTableWidget instead.</p>
<p dir="auto">I was maintaining a QList &lt;QLineEdit *&gt; for all the QLineEdit in GUI. But now since I am using QTableWidget in the GUI, I want that the GUI should interact with my QList &lt;QLineEdit *&gt; in the background. So I thought of using setCellWidget(). Now as you say that also severly affects the performance what should I do? Now you will ask why I am using QLineEdit. Thats because I am using a QDoubleValidator on that. Plus some other properties specific to QLineEdit.</p>
<p dir="auto">I cannot remove the QList as all the functions in my classes depend on it. In the thread you mentioned above, there was something about delegate. Do you think that using delegate is the solution to my problem? If yes can you please show me some code for how to use it? If no then what do you suggest?</p>
]]></description><link>https://forum.qt.io/post/172829</link><guid isPermaLink="true">https://forum.qt.io/post/172829</guid><dc:creator><![CDATA[CAD_coding]]></dc:creator><pubDate>Sun, 07 Apr 2013 12:59:40 GMT</pubDate></item><item><title><![CDATA[Reply to QTableWidget::setCellWidget() a QLineEdit for very large table? on Sun, 07 Apr 2013 12:22:34 GMT]]></title><description><![CDATA[<p dir="auto">bq. Instead I wanted to ask what is the effect of adding QLineEdit through setCellWidget() for each cell.</p>
<p dir="auto">The best thing is to create a sample program and test with your specifications.</p>
<p dir="auto">bq. I want to know whether there is any impact on speed on my application?<br />
The tablewidget has &gt;10,000 rows &amp; &gt;10,000 columns.</p>
<p dir="auto">If you are using setCellWidget the performance will drop heavily e.g. loading the data at startup from database / adding multiple items in a for loop. You can have a look at "this":<a href="http://qt-project.org/forums/viewthread/25076/" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/forums/viewthread/25076/</a> thread for more details.</p>
]]></description><link>https://forum.qt.io/post/172826</link><guid isPermaLink="true">https://forum.qt.io/post/172826</guid><dc:creator><![CDATA[Sam]]></dc:creator><pubDate>Sun, 07 Apr 2013 12:22:34 GMT</pubDate></item></channel></rss>