Is it possible to use busy progressbar in QListView?



  • I created my own model that store some text and other data. Then I create my ItemDelegate that is inherited from QAbstractItemDelegate. Inside function paint I setup QProgressBar from model. But the problem is that busy progressbar doesn't work, it display progress bar with no activity. It's look like QListView display only static data. Is there any way to make busy progress bar look properly?
    My implementation of paint method:
    @void StatusItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
    {
    StatusItem my_item = index.data().value<StatusItem>();
    wdg->name->setText(my_item.m_name);
    switch (my_item.m_state)
    {
    case 0: wdg->progress->setMaximum(0); wdg->progress->setMinimum(0); break;
    case 1: wdg->progress->setRange(0, 0); wdg->progress->setValue(100); break;
    case 2: wdg->progress->setHidden(true); break;
    }
    QPalette pal;
    QLinearGradient gradient(0, 0, 0, 100);

    if ((option.state & QStyle::State_Selected) == QStyle::State_Selected)
    {
        pal.setBrush(QPalette::Window, QBrush(QColor(0, 255, 200)));
    }
    else
    {
        gradient.setColorAt(0.0, QColor(255,250,0));
        gradient.setColorAt(1.0, QColor(255,255,255));
        pal.setBrush(QPalette::Window, QBrush(QColor(Qt::transparent)));
        pal.setBrush(QPalette::Window, QBrush(gradient));
    }
    

    wdg->setPalette(pal);
    wdg->resize(option.rect.size());
    painter->save();
    painter->setRenderHint(QPainter::Antialiasing, true);
    painter->translate(option.rect.topLeft());
    wdg->render(painter);

    painter->restore();
    }@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.