Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Need help inserting something in Qt tree view with python
Forum Updated to NodeBB v4.3 + New Features

Need help inserting something in Qt tree view with python

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.8k Views 1 Watching
  • 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 Offline
    S Offline
    shizzo
    wrote on last edited by
    #1

    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
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved