简体   繁体   中英

How to resize QInputDialog, PyQt

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.

it is possible by doing this:

dlg =  QtGui.QInputDialog(self)                 
dlg.setInputMode( QtGui.QInputDialog.TextInput) 
dlg.setLabelText("URL:")                        
dlg.resize(500,100)                             
ok = dlg.exec_()                                
url = dlg.textValue()

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 a QWidget instance, so you can't call resize() on it.

If you want to call resize() , you need to create your own QWidget (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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM