qtreeview

QTreeView with drag and drop support in PyQt

﹥>﹥吖頭↗ 提交于 2019-11-29 12:45:04
问题 In PyQt 4 I would like to create a QTreeView with possibility to reorganize its structure with drag and drop manipulation. I have implemented my own model(QAbstractItemModel) for QTreeView so my QTreeView properly displays the data. Now I would like to add drag and drop support for tree's nodes to be able to move a node inside the tree from one parent to another one, drag-copy and so on, but I cannot find any complete tutorial how to achieve this. I have found few tutorials and hints for

Selecting a row in QTreeView programmatically

最后都变了- 提交于 2019-11-29 01:27:30
I have a QTreeView with QFileSystemModel as model. The QTreeView has SelectionBehavior set to SelectRows. In my code I read a dataset to select and then select them via: idx = treeview->model()->index(search); selection->select(idx, QItemSelectionModel::Select); This selects a cell, not the row . . Have added a stupid workaround, but would rather fix this the correct way. for (int col=0; col< treeview->model()->columnCount(); col++) { idx = treeview->model()->index(search, col); selection->select(idx, QItemSelectionModel::Select); } Or is that ^^ the only way to do it? You can also select an

PyQt Tree Widget, adding check boxes for dynamic removal

为君一笑 提交于 2019-11-29 00:10:40
问题 I am attempting to create a tree widget that will essentially allow the user to view various breakdowns of data and have the option to delete certain items. In order to do this I want to have check boxes associated with each top level item and each child so the user can select which top level items (and thus all the children of that top level item) to delete. Or which specific children to delete. To give you a better idea I've created an example where [x] represents a checked check box and [

Adding a right-click menu for specific items in QTreeView

本小妞迷上赌 提交于 2019-11-28 17:30:28
I'm writing a Qt desktop application in c++ with Qt Creator. I declared in my main window a treeView, and a compatible model. Now, I would like to have a right-click menu for the tree item. Not for all of the items, but for a part of them, for example: for the tree elements with an even index. I tried adding a simple context menu with the following code: in the .h file: QStandardItemModel* model; QMenu* contextMenu; QAction* uninstallAction; private slots: void uninstallAppletClickedSlot(); and in the .cpp file: in the constructor: ui->treeView->setModel(model); contextMenu = new QMenu(ui-

How to save PySide tree view model structure

旧时模样 提交于 2019-11-28 13:12:32
Here is the link on other SO question QTreeView with custom items where is QTreeView example. Please, can anyone explain me at this example, how to save tree structure from treeview. Is the QAbstractItemModel class from which I can extract label names, and structure which I could load again? If so, how could I access to nodes? Any other way except index? EDIT (from the link) : import sys from PySide import QtGui, QtCore #------------------------------------------------------------------------------- # my test data class Icon(): def __init__(self, icon, tooltip): self.pixmap = QtGui.QPixmap

PyQt QFileDialog - Multiple Directory Selection

蓝咒 提交于 2019-11-28 05:04:58
问题 I am trying to create a QFileDialog that allows the user to select multiple directories. Following the discussion here and the faq here, but I'm not sure what I'm doing wrong. I get a file dialog, but it still only lets me select a single directory (folder). This is on Windows 7 Code: class FileDialog(QtGui.QFileDialog): def __init__(self, *args): QtGui.QFileDialog.__init__(self, *args) self.setOption(self.DontUseNativeDialog, True) self.setFileMode(self.DirectoryOnly) self.tree = self

Selecting a row in QTreeView programmatically

偶尔善良 提交于 2019-11-27 15:57:26
问题 I have a QTreeView with QFileSystemModel as model. The QTreeView has SelectionBehavior set to SelectRows. In my code I read a dataset to select and then select them via: idx = treeview->model()->index(search); selection->select(idx, QItemSelectionModel::Select); This selects a cell, not the row . . Have added a stupid workaround, but would rather fix this the correct way. for (int col=0; col< treeview->model()->columnCount(); col++) { idx = treeview->model()->index(search, col); selection-

How to save PySide tree view model structure

穿精又带淫゛_ 提交于 2019-11-27 07:33:17
问题 Here is the link on other SO question QTreeView with custom items where is QTreeView example. Please, can anyone explain me at this example, how to save tree structure from treeview. Is the QAbstractItemModel class from which I can extract label names, and structure which I could load again? If so, how could I access to nodes? Any other way except index? EDIT (from the link) : import sys from PySide import QtGui, QtCore #------------------------------------------------------------------------

How to make item view render rich (html) text in Qt

眉间皱痕 提交于 2019-11-26 11:44:52
Suppose my model has items with the following string for Qt::DisplayRole <span>blah-blah <b>some text</b> other blah</span> I want QTreeView (actually, any item view) to render it like a rich text. Instead, item views render it like a pure text by default. How to achieve the desired rendering? Actually, this is a search results model. User enters a text, some document is searched against that text and the user is presented with search results, where the words being searched should be bolder than surrounding text. serge_gubenko I guess you can use setItemDelegate method of the treeview to setup