[英]How to get a QProgressBar in QT with rounded edges and rounded progress edges?
我創建了一個垂直進度條,並嘗試用圓角設置它的樣式。 無論我做什么,我似乎都無法獲得帶有圓角邊緣的進度條(QProgressBar::chunk)的進度或塊。 請幫幫我,我是QT的新手。
請在下面找到我的代碼:-
progressbar_V = new QProgressBar;
progressbar_V->setParent(this);
progressbar_V->setMinimum(0);
progressbar_V->setMaximum(5);
progressbar_V->setValue(3);
progressbar_V->setStyleSheet("QProgressBar{ border: solid grey; border-width: 6; border-radius: 12; color: black; text-align: centre; margin-right: 12; }, QProgressBar::chunk:vertical {background-color: #05B8CC; width: 20px;}");
progressbar_V->setGeometry(250,250,60,300);
progressbar_V->setOrientation(Qt::Vertical);
進度條文本也位於輸出的頂部。 我將如何讓它到垂直進度條的中間
你是對的,你可以使用這個參數:
border-radius: 50px;
獲得圓形邊界! 但是您只是忘記在最后指定px
因此,一旦您的代碼更新,它看起來像這樣:
progressbar_V->setStyleSheet("QProgressBar{ border: solid grey; border-width: 6; border-radius: 12px; color: black; text-align: centre; margin-right: 12; }, QProgressBar::chunk:vertical {background-color: #05B8CC; width: 20px;}");
您需要將樣式表更改為如下內容:
progressbar_V->setStyleSheet("QProgressBar{border:solid gray;border-bottom-right-radius:12px;border-bottom-left-radius:12px;顏色:黑色;text-align:center;},QProgressBar::chunk {背景顏色:#05B8CC;邊框底部右半徑:7px;邊框底部左半徑:7px;}");
快樂的編碼..
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.