如何调整 QInputDialog、PyQt 的大小
我在这里得到输入
areaInput = QtGui.QInputDialog.getText(self, "Copy Area", "New Area Name:", 0)
但是我想让对话框更大,我已经尝试过诸如此类的事情
QtGui.QInputDialog.resize(400, 400)
但是它说“第一个参数必须是 QWidget 类”,我不太确定这意味着什么或如何修复它。谢谢。
I am getting input with this here
areaInput = QtGui.QInputDialog.getText(self, "Copy Area", "New Area Name:", 0)
However I would like to make the dialog box larger, I've tried things such as
QtGui.QInputDialog.resize(400, 400)
However it says "the first argument must be a QWidget class" and I'm not quite sure what this means or how to fix it. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这样做是可能的:
it is possible by doing this:
该错误意味着您没有使用实例调用实例方法。
QtGui.QInputDialog.getText()
是静态方法,不会返回QWidget
实例,因此您无法调用resize()
关于它。如果你想调用
resize()
,你需要创建你自己的QWidget
(或QDialog)。That error implies that you're not calling an instance method with an instance.
QtGui.QInputDialog.getText()
is a static method and doesn't return you aQWidget
instance, so you can't callresize()
on it.If you want to call
resize()
, you need to create your ownQWidget
(or QDialog).我也有同样的问题。主要是窗口水平方向太窄,导致文本编辑输入字段很小。我最终在标签参数的文本后面放置了很多空格。对我来说效果很好。
I had the same problem. Mainly that the window was too narrow horizontally, making the text edit input field small. I ended up putting lots of whitespace after the text in the label argument. Worked fine for me.