Issue
I'm trying to access Qt
elements that are loaded via .ui file. However I'm getting error:
AttributeError: 'TreeviewWidgetSelectProve' object has no attribute '_treeview'
Full python code and .ui file are available in those links respectively. Code snippet:
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)
Whether I use findChild
suggested in this thread doesn't change the situation. It returns NoneType
if in use.
What is wrong? Thank you!
python-pyside 1.1.1-3 on Ubuntu Quantal
Solution
I'm afraid your .ui file is broken. Have you tried opening it in the QtDesigner? When I do that it reports an error. So I recreated the file with QtDesigner (just a QMainWindows with a QTreeView) and your problem disappears.
There are plenty of other problems though:
self has no member uiw (line 33 and 38)
passing the instance of TreeviewWidgetSelectProve to the QUiLoader does not work as far as I know, thats why I had to implement a custom loader: https://github.com/ros-visualization/python_qt_binding/blob/groovy-devel/src/python_qt_binding/binding_helper.py#L199
Answered By - Dorian Scholz
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.