开发者

Casting a QDialog to QWidget

开发者 https://www.devze.com 2023-02-15 07:15 出处:网络
I lost my .ui file, and it seems pyuic4 cannot make a .ui file out of a .py file, only the other way around.

I lost my .ui file, and it seems pyuic4 cannot make a .ui file out of a .py file, only the other way around.

I have a QDialog, and I am now instead going to put its content开发者_如何学C inside a tab-pane. For that I need a widget, not a "stand-alone" dialog.

How can I cast QDialog to QWidget, or is there any other workaround other than doing the whole design over again.

Thanks


If I understand you correctly, you have a custom class that drives from QDialog, but you would now like to use it inside a tab pane rather than standalone.

For that the simplest path is to change your class to inherit from QWidget directly rather than QDialog. There should be little to no code change in that class (except for the obvious stuff in the constructor).

(I have no idea what your .ui problem has to do with this though.)

Also, QDialog inherits from QWidget. No type-casting necessary to use a QDialog when a QWidget is expected.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号