Qt进度条能否显示自定义文字

加盾男爵 2017-11-14 11:22:30
程序需要显示一个进度条,然后希望在进度条读取的时候,在进度条上显示文字

“正在执行34%。。。”
其中数字为百分比,其他文字均为固定的文字

现在为了在进度条上显示这段文字,我只能子类化QProGressBar类,然后重写绘图事件,在绘图里面绘制文本,然后进度条每次加载值(调用setValue(int))的时候重新绘制窗体,我想问下有没有别的更简单点的办法
...全文
1149 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
dext 2017-11-14
  • 打赏
  • 举报
回复
QProgressBar::format : QString
This property holds the string used to generate the current text
%p - is replaced by the percentage completed. %v - is replaced by the current value. %m - is replaced by the total number of steps.
The default value is "%p%".
This property was introduced in Qt 4.2.
Access functions:

QString
format() const
void
setFormat(const QString &format)
void
resetFormat()

See also text().

16,225

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧