如何在Qt中将一个小部件放置在另一个上 [英] How to place one widget over another in Qt

查看:521
本文介绍了如何在Qt中将一个小部件放置在另一个上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Qt中有一个窗口,我正在画一幅画.现在我要在其上放置进度条. 我该怎么办?..

i have a window in Qt, on that i am drawing a picture. now i want to place the progressbar over it. how can i do that?..

我要执行的步骤

  1. 创建一个窗口

  1. Create a window,

在窗口的绘制事件中绘制图片

Draw picture in paint event of window

然后创建QGridLayout布局,添加您的窗口

Then create QGridLayout layout, add your window

在其上方显示.

假设我要在图片窗口的一部分上添加进度条.我该怎么办

suppose i want to add progress bar, over a portion of picture window. how can i do that

我认为不可能在窗口绘制事件中实现.

i dont think its possible to implement in window paint event.

请帮助我

谢谢

推荐答案

您可以将进度条添加为QWidget的子级,而无需在布局中添加它.这会将QProgressBar绘制到QWidget中.由于未使用布局,因此必须手动管理QProgressBar的位置.

You can add the progress bar as child of your QWidget without adding it in the layout. This will draw the QProgressBar into the QWidget. Since you are not using the layout you will have to manually manage the position of the QProgressBar.

这篇关于如何在Qt中将一个小部件放置在另一个上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆