qt - QProgressBar as semi-transparent overlay -
i have been pulling out hair trying figure out how this. tried using stylesheets, no avail. on #qt said got work, when adapted code, widgets go transparent, unfortunately not qprogressbar
#include <qapplication> #include <qprogressbar> int main(int argc, char *argv[]) { qapplication a(argc, argv); qwidget *widget = new qwidget(); qprogressbar *progress = new qprogressbar(widget); qpalette palette(widget->palette()); palette.setcolor(widget->backgroundrole(), qt::green); widget->setautofillbackground(true); widget->setpalette(palette); qpalette palette1(progress->palette()); palette1.setcolor(progress->backgroundrole(), qt::transparent); progress->setautofillbackground(true); progress->setpalette(palette1); widget->show(); return a.exec(); }
just in case wondering why want this; trying have overlay icon of deck of cards, grab, shrinks. want transparently on icon in order save space.
any ideas?
i don't know if have special reason not stylesheets, or if couldn't work stylesheets, here solution transparency problem using stylesheets:
progress->setstylesheet("qprogressbar{" "border: 1px solid transparent;" "text-align: center;" "color:rgba(0,0,0,100);" "border-radius: 5px;" "background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(182, 182, 182, 100), stop:1 rgba(209, 209, 209, 100));" "}" "qprogressbar::chunk{" "background-color: rgba(0,255,0,100);" "}");
you can adjust own liking.
Comments
Post a Comment