Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Is it possible to use busy progressbar in QListView?
Forum Updated to NodeBB v4.3 + New Features

Is it possible to use busy progressbar in QListView?

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sunrise13
    wrote on last edited by
    #1

    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();
    }@

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved