[PyQt] display a widget in a QTableView

Wim Verhavert wim.verhavert at gmail.com
Fri Oct 17 13:19:26 BST 2008


I have found some more information on this issue:

It seems to be related with my theme (I'm on Windows XP here). If I
change my theme to the old-style Windows theme, I don't need to
enlarge the column that much. I have noticed that PyQT uses the
build-in 'stepped' progressbar. Is there a way to use a continuous
type of progressbar? I can't seem to find anything in the
documentation.

Cheers!

--
Wim

On Fri, Oct 17, 2008 at 11:00 AM, Wim Verhavert <wim.verhavert at gmail.com> wrote:
> This seems to work. Thanks! It helped me a lot to think about the
> problem. One thing though: the actual value is only displayed when I
> increase the width of my cell enough. I included 2 screenshots as
> illustration. Can I control this with some options? I do not want to
> increase the size this much if possible.
>
> On Thu, Oct 16, 2008 at 7:06 PM, Kovid Goyal <kovid at kovidgoyal.net> wrote:
>> class ProgressBarDelegate(QAbstractItemDelegate):
>>
>>    def sizeHint(self, option, index):
>>        return QSize(120, 30)
>>
>>    def paint(self, painter, option, index):
>>        opts = QStyleOptionProgressBarV2()
>>        opts.rect = option.rect
>>        opts.minimum = 1
>>        opts.maximum = 100
>>        opts.textVisible = True
>>        percent, ok = index.model().data(index, Qt.DisplayRole).toInt()
>>        if not ok:
>>            percent = 0
>>        opts.progress = percent
>>        opts.text = QString(_('Unavailable') if percent == 0 else
>> '%d%%'%percent)
>>        QApplication.style().drawControl(QStyle.CE_ProgressBar, opts, painter)
>>
>> On Thursday 16 October 2008 09:50:54 Wim Verhavert wrote:
>>> Dear all,
>>>
>>> I want to do something in PyQT I have seen many times in other
>>> applications: A QTableView where the last column contains a QProgressbar.
>>> Basically I want to implement some kind of cue where each item is processed
>>> which can take a while. To give some visual feedback I want to display
>>> a progressbar in the last column. This would allow sorting on progress
>>> and such.
>>> I have the book 'Rapid GUI Programming with Python and Qt' by Mark
>>> Summerfield at hand which contains a section about custom delegates. I
>>> have done similar things in the past, but somehow I'm not able to
>>> translate this into the thing I want to do. Is there somebody out
>>> there that could give me a head start?
>>>
>>> I think it will need to create a custom delegate and override the
>>> paint method. But how? How do I paint a progressbar? Do I have to do
>>> this from scratch, i.e. filling a part of the cell with a color, or
>>> can I use a QProgressbar? Any suggestions are welcome.
>>>
>>> Cheers!
>>>
>>> Wim
>>> _______________________________________________
>>> PyQt mailing list    PyQt at riverbankcomputing.com
>>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>>>
>>> !DSPAM:3,48f771b131535171880063!
>>
>> --
>> _____________________________________
>>
>> Kovid Goyal  MC 452-48
>> California Institute of Technology
>> 1200 E California Blvd
>> Pasadena, CA 91125
>>
>> cell  : +01 626 390 8699
>> office: +01 626 395 6595 (449 Lauritsen)
>> email : kovid at theory.caltech.edu
>> web   : http://www.kovidgoyal.net
>> _____________________________________
>>
>>
>> _______________________________________________
>> PyQt mailing list    PyQt at riverbankcomputing.com
>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>>
>


More information about the PyQt mailing list