2017-03-03 47 views
0

我想添加一個「whats this」值到QInputDialog框,具體getInt。如何將「whats this」屬性添加到QInputDialog中?

我不知道如何做到這一點,文件沒有幫助我。我試過這個:

tmp = QInputDialog() 
tmp.setWhatsThis('What is this?') 
self.seed = tmp.getInt(self, 'Seed', 'Please enter the RNG seed now', self.seed)[0] 

但是,當我點擊對話框上的小問號時,沒有任何反應。我認爲我可以通過製作一個自定義類來做到這一點,但對於如此簡單的事情來說,這看起來有很多工作要做。

+0

'getInt'是一種靜態方法。它會忽略您創建的實例。 –

回答

1

使用static functionsgetInt時不能這樣做。您需要手動執行所有操作:

dialog = QInputDialog(self) 
dialog.setWindowTitle('Seed') 
dialog.setLabelText('Please enter the RNG seed now') 
dialog.setInputMode(QInputDialog.IntInput) 
dialog.setIntValue(self.seed) 
dialog.setWhatsThis('What is this?') 
if dialog.exec() == QDialog.Accepted: 
    self.seed = dialog.intValue()