QprogressDialog 居中显示
时间: 2023-08-10 08:07:47 浏览: 127
要使QProgressDialog居中显示,可以使用以下代码:
```cpp
QProgressDialog dialog("对话框名称", "", 0, 最大范围, this);
dialog.setWindowFlags(Qt::FramelessWindowHint);
dialog.setWindowModality(Qt::WindowModal);
dialog.setMinimumDuration(0);
dialog.setStyleSheet("QProgressDialog{background-image: url(:/图片名称.png);}");
dialog.setFixedSize(500, 200);
dialog.move((this->width() - dialog.width()) / 2, (this->height() - dialog.height()) / 2);
dialog.show();
```
在这段代码中,我们使用`move()`函数将对话框移动到父窗口的中心位置,从而实现居中显示。
#### 引用[.reference_title]
- *1* [QT开发之QProgressDialog进度条对话框](https://blog.csdn.net/bigtree_mfc/article/details/102910407)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* *3* [自定义ProgressDialog 居中方形显示进度条](https://blog.csdn.net/u011884112/article/details/51884032)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文