Python 如何使用PySide灰显/具有不可见元素?
我正在用PySide编写一个接口,我希望在执行另一个操作之前,该接口的某些元素将变灰/不可见/不可访问(例如,在加载文件之前计算文件中的单词是没有意义的),我认为这应该是可能的,但我似乎找不到方法 例如,我创建了以下菜单:Python 如何使用PySide灰显/具有不可见元素?,python,qt,pyside,Python,Qt,Pyside,我正在用PySide编写一个接口,我希望在执行另一个操作之前,该接口的某些元素将变灰/不可见/不可访问(例如,在加载文件之前计算文件中的单词是没有意义的),我认为这应该是可能的,但我似乎找不到方法 例如,我创建了以下菜单: # We create the actions for the edit menu countAction = QtGui.QAction(QtGui.QIcon('exit.png'), '&Count', self)
# 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)
如何使此菜单以及稍后的按钮和文本字段在发生特定事件(加载文件)之前不可执行?Qt中的许多对象可以使用
setEnabled(False)
灰显,并使用setEnabled(True)
重新启用。将其应用于QAction。Qt中的许多对象可以使用setEnabled(False)
灰显,并使用setEnabled(True)
重新启用。把它应用到QAction上。谢谢,我知道我忽略了一些简单的东西。谢谢,我知道我忽略了一些简单的东西。