我試圖訪問通過.ui文件加載的Qt
元素。但是我得到的錯誤:如何使用PySide讀取.ui文件中的小部件
AttributeError: 'TreeviewWidgetSelectProve' object has no attribute '_treeview'
完全python code和.ui file分別是在這些鏈接可用。代碼片段:
ui_file_path = os.path.join(
'/home/userdaze/pyside_test', 'resource', 'treeview.ui')
loader = QUiLoader(self)
ui_file = QFile(ui_file_path)
self._widget_top = loader.load(ui_file, self)
self._treeview = self._widget_top.findChild(QTreeView, '_treeview')
self._treeview.setModel(self._std_model)
無論我用findChild
在this thread建議不改變的情況。如果正在使用,則返回NoneType
。
出了什麼問題?謝謝!
Ubuntu的量子理論中的python-pyside 1.1.1-3
對不起,我搞砸了代碼以某種方式同時去除不必要的部分。現在他們被更新了。 – IsaacS 2013-03-01 20:09:01