我正在用PySide編寫接口,我希望接口的某些元素在執行其他操作之前變灰/不可見/不可訪問(例如,在文件被加載之前,對文件中的單詞進行計數是沒有意義的)我認為這應該可行,但我似乎找不到方法。例如,我創建此菜單: # 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)在出現某個事件(文件加載)之前,如何使該菜單以及稍后在按鈕和文本字段上無法訪問?
1 回答
寶慕林4294392
TA貢獻2021條經驗 獲得超8個贊
使用可以將Qt中的許多對象顯示為灰色,并使用可以setEnabled(False)重新啟用它們setEnabled(True)。將其應用于QAction。
添加回答
舉報
0/150
提交
取消
