将QDialog嵌入QWidget的简单方法 [英] Simple way to embed a QDialog into a QWidget
问题描述
我一直在寻找一个简单的方法来在 QWidget
中嵌入 QDialog
实例,但是我发现使用OpenGL或一些相当复杂的东西来实现。实际上,我发现的所有例子试图实现更多的东西,而不仅仅是嵌入 QDialog
。所以,我想知道:有没有一个简单而干净的方式来嵌入一个 QDialog
在一个 QWidget
?
I have been searching for a simple way to embed QDialog
instances in a QWidget
, but all I found used OpenGL or some rather complex stuff to achieve that. Actually, all the examples I found tried to achieve many more things than simply embed the QDialog
. So, I am wondering: is there a simple and clean way to embed a QDialog
in a QWidget
?
PS:我标记了 pyqt ,因为它是我正在使用的,但是我当然会接受c ++的答案:)
P.S.: I tagged pyqt since it's what I'm using, but I will of course accept c++ answers :)
这是一个屏幕捕获我必须移植的软件,我需要这样一个功能。
Here is a screen capture of the piece of software I have to port and for which I kind of need such a feature.
推荐答案
您应该使用 QMdiArea
。
widget = QWidget()
mdiarea = QMdiArea()
layout = QVBoxLayout(widget)
layout.addWidget(mdiarea)
d = QInputDialog()
d.setLabelText("test2")
d.setInputMode(QInputDialog.TextInput)
w = mdiarea.addSubWindow(d)
w.show()
widget.show()
这篇关于将QDialog嵌入QWidget的简单方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!