我正在用PySide編寫接口,我希望接口的某些元素在執(zhí)行其他操作之前變灰/不可見/不可訪問(例如,在文件被加載之前,對文件中的單詞進(jìn)行計(jì)數(shù)是沒有意義的)我認(rèn)為這應(yīng)該可行,但我似乎找不到方法。例如,我創(chuàng)建此菜單: # We create the actions for the edit menu countAction = QtGui.QAction(QtGui.QIcon('exit.png'), '&Count', self) countAction.setShortcut('Ctrl+C') countAction.setStatusTip('Counts the points in the current point cloud') #openAction.triggered.connect(self.close) # We create the menus editMenu = menuBar.addMenu('&Edit') # We add the actions to the edit menu editMenu.addAction(countAction)在出現(xiàn)某個(gè)事件(文件加載)之前,如何使該菜單以及稍后在按鈕和文本字段上無法訪問?
1 回答

寶慕林4294392
TA貢獻(xiàn)2021條經(jīng)驗(yàn) 獲得超8個(gè)贊
使用可以將Qt中的許多對象顯示為灰色,并使用可以setEnabled(False)
重新啟用它們setEnabled(True)
。將其應(yīng)用于QAction。
添加回答
舉報(bào)
0/150
提交
取消