Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you are using <code>QTableView</code>, I presume you use a model linked to this view.</p> <p>One solution would be to use delegates (see <code>QItemDelegate</code>) to paint the progress, In <code>QItemDelegate::paint</code> method you have to define, use <code>QStyle</code> of the widget (<code>widget-&gt;style()</code>) to paint the progress (use <code>QStyle::drawControl</code> with <code>QStyle::CE_ProgressBarContents</code> as control identifier).</p> <p>Check the documentation from the example Star Delegate, to see how to define the delegate for the column you need.</p> <p><strong>Later edit:</strong> Example of defining the delegate paint method (code sketch, not really tested, take it as a principle, not fully working).</p> <pre><code>void MyDelegate::paint ( QPainter * painter, const QStyleOptionViewItem &amp; option, const QModelIndex &amp; index ) const { QStyleOptionProgressBar progressStyle; progressStyle.rect = option.rect; // Maybe some other initialization from option would be needed // For the sake of the example, I assume that the index indicates the progress, and the next two siblings indicate the min and max of the progress. QModelIndex minIndex = index.sibling( index.row(), index.column() + 1); QModelIndex maxIndex = index.sibling( index.row(), index.column() + 2); progressStyle.minimum = qvariant_cast&lt; int&gt;( minIndex.data( Qt::UserRole)); progressStyle.maximum = qvariant_cast&lt; int&gt;( maxIndex.data( Qt::UserRole)); progressStyle.progress = qvariant_cast&lt; int&gt;( index.data( Qt::UserRole)); progressStyle.textVisible = false; qApp-&gt;style()-&gt;drawControl( QStyle::CE_ProgressBarContents, progressStyleOption, painter); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload