[問題] 請問儀錶板功能要怎樣做會比較好呢?

看板C_and_CPP作者 (談無慾)時間7年前 (2016/11/22 16:56), 編輯推噓3(301)
留言4則, 3人參與, 最新討論串1/1
開發平台(Platform): (Ex: Win10, Linux, ...) vs 2015 編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出) qt 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 問題(Question): 我需要做一個儀表板 類似這樣 https://www.microsoft.com/zh-tw/dynamics/crm-customer-center/Tile_buttons.PNG
我目前是自己寫一個widget(widget.cpp) 然後在主ui(dashboard.cpp)把他塞進一個QFrame 這是我最後的結果 http://imgur.com/WupfSts
不知道還能不能有更好的寫法呢? =========dashboard.cpp===== dashboard::dashboard(QWidget *parent) : QMainWindow(parent) { ui.setupUi(this); s1 = new QSlider(this); s1->setGeometry(450, 150, 20, 100); w1 = new Widget(ui.frame); ui.frame->setStyleSheet("QFrame{border-image:url(Image/back.PNG)}"); w1 ->resize(400, 400); connect(s1, SIGNAL(valueChanged(int)), w1, SLOT(setProgress(int))); connect(s1, SIGNAL(valueChanged(int)), w2, SLOT(setProgress(int))); } =======widget.cpp============= void Widget::paintEvent(QPaintEvent *) { QPainter p(this); QPen pen; pen.setWidth(10); pen.setStyle(Qt::DotLine); p.setPen(pen); p.setRenderHint(QPainter::Antialiasing); QRectF rectangle(5.0, 5.0, 200.0, 200.0); int startAngle = 180 * 16; int spanAngle = -progress * 360 * 8; //qDebug() << "progress: " << progress; p.drawArc(rectangle, startAngle, spanAngle); p.drawText(rectangle, Qt::AlignCenter, QString::number(progress * 100) + " %"); } -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 59.124.46.66 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1479804963.A.E26.html

11/22 21:14, , 1F
我想像中的儀表板 vs 我的儀表板
11/22 21:14, 1F

11/22 21:15, , 2F
應該是畫兩個半徑不同的扇形相減?沒經驗只是想法
11/22 21:15, 2F

11/22 23:58, , 3F
goo.gl/2wBD2z
11/22 23:58, 3F

11/23 12:51, , 4F
怎麼不用qml.....
11/23 12:51, 4F
文章代碼(AID): #1OD0WZuc (C_and_CPP)