Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Need help inserting something in Qt tree view with python

    General and Desktop
    1
    1
    2780
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      shizzo last edited by

      Hi

      I want to get a Tree View running with PySide for that i used Qt Designer to get the window.
      To compile my GUI code into Python code i used the pyuic compiler and i got a form.py
      which is a module containing my dialog as a Python class and looks like this:

      @class Ui_SleuthGUI(object):
      def setupUi(self, SleuthGUI):
      SleuthGUI.setObjectName("SleuthGUI")
      ...
      self.tvDirTree = QtGui.QTreeView(self.centralwidget)
      self.tvDirTree.setGeometry(QtCore.QRect(20, 120, 311, 451))
      self.tvDirTree.setObjectName("tvDirTree")
      ...@

      Now i didn't know how to write the python code to insert something in my treeview.
      I tried plenty of things wich i found on the internet but nothing worked.
      PyQt4 and PySide are installed.

      @from PySide import QtGui, QtCore
      from sleuthGUI_ui import Ui_SleuthGUI

      self.ui.tvDirTree.itemDelegateForColumn(1)
      items = []
      for i in range(10):
      items.append(QtGui.QTreeWidgetItem(None, QStringList(QString('item: %1').arg(i))))
      self.ui.tvDirTree.insertTopLevelItems(None, items)
      self.ui.tvDirTree.insertAction(None, items)
      @
      Another Problem is that PySide does not know QStringList or QString so i tried it with PyQt4.
      But i could not insert anything.

      Could anybody help me please?

      1 Reply Last reply Reply Quote 0
      • First post
        Last post