qtreeview

Multi-level QTreeView

放肆的年华 提交于 2019-12-04 10:16:32
I'm having a hard time understanding how to set a multilevel QTree using the QTreeView and QStandardItemModel. Here's what I have: from PySide.QtGui import * import sys class MainFrame(QWidget): def __init__(self): QWidget.__init__(self) tree = {'root': { "1": ["A", "B", "C"], "2": { "2-1": ["G", "H", "I"], "2-2": ["J", "K", "L"]}, "3": ["D", "E", "F"]} } self.tree = QTreeView(self) root_model = QStandardItemModel() self.tree.setModel(root_model) for r,root in enumerate(sorted(tree)): root_item = QStandardItem(root) root_model.setItem(r,root_item) for c,child in enumerate(sorted(tree[root])):

Can I call page_load event of usercontrol before page_load event of aspx page?

北城以北 提交于 2019-12-04 05:54:34
问题 The question is straight forward.Can I call page_load of usercontrol before page_load of aspx page? EDIT Its not possible to call the child's page_load event before parent's page_load. I have this aspx class called just4test for testing puropse. Its aspx code is: <body> <form id="form1" runat="server"> <uc1:lcont ID="lcont1" runat="server" /> <div> </div> </form> As you can see it is using a usercontrol file. And its code behind is : protected void Page_Load(object sender, EventArgs e) { if

QTreeView draw drop indicator

前提是你 提交于 2019-12-04 05:17:40
I need to implement rows moving via drag-n-drop in QTreeView and show the drop indicator between rows. I am wondering if there is a way to override indicator drawing, so it is displayed for all levels of hierarchy between rows only (not the rectangle around the item), the line must be as wide as the entire row (not as the one column). It is possible by modyfing style used to draw widget. My attempt seemed to work well, but it's a bit of cheating the qt's style system, so i cannot guarante that it will work under all possible styles on all platforms. So here it is: class myViewStyle: public

PyQT — How can you make a QTreeview uneditable but also selectable?

流过昼夜 提交于 2019-12-03 13:43:42
I just switched from wxPython to PyQT and I am having some trouble with the QTreeview. I have a QTreeview that will display data categorized into sections that are expandable, but the data in this TreeView should not be editable, but I need to be able to have the user select the data (doubleclicking is going to execute another method). I am not certain how to make it readonly but also selectable. I am using the QStandardItemModel with the QStandardItem to hold the data. Any help would be much appreciated. You can set individual items to be uneditable by doing this when you create the

QFileSystemModel setRootPath

天涯浪子 提交于 2019-12-03 11:53:46
I am attempting to create a Qt application which shows the contents of a folder (“Users” folder in Mac OS). Here is the code: QFileSystemModel *dirModel = new QFileSystemModel; dirModel->setRootPath("/Users"); ui->listView->setModel(dirModel); I also attempted using this code When i run the application, instead of showing the content of the “/Users” Folder, it shows the root drive (note: not the content of the drive). The folder does exist and i also tried using other folders. Did you try forcing the index to show the directory ? listView->setRootIndex(dirModel->index("/Users")); This works

Python: PyQt QTreeview example - selection

倾然丶 夕夏残阳落幕 提交于 2019-12-03 09:40:44
问题 I'm using Python 2.7 and Qt designer and I'm new to MVC: I have a View completed within Qt to give me a directory tree list, and the controller in place to run things. My question is: Given a Qtree view, how may I obtain a directory once a dir is selected? Code snap shot is below, I suspect it's SIGNAL(..) though I'm unsure: class Main(QtGui.QMainWindow): plot = pyqtSignal() def __init__(self): QtGui.QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) # create model

QT QItemSelectionModel to ignore columns?

戏子无情 提交于 2019-12-02 10:25:29
问题 I am trying to restrict selection of a tree to a particular column. I am using delegates heavily to create custom per-item-per-column behaviors, editors, etc. I was hoping I could somehow do this from a delegate by blocking an event or something similar. The problem is, I think i would have to create an entirely custom solution that mimics extended selection. However, after a lot of searching and very few examples, it sounds like I want a custom QItemSelectionModel on my tree view. Is this

Can I call page_load event of usercontrol before page_load event of aspx page?

北城余情 提交于 2019-12-02 09:05:51
The question is straight forward.Can I call page_load of usercontrol before page_load of aspx page? EDIT Its not possible to call the child's page_load event before parent's page_load. I have this aspx class called just4test for testing puropse. Its aspx code is: <body> <form id="form1" runat="server"> <uc1:lcont ID="lcont1" runat="server" /> <div> </div> </form> As you can see it is using a usercontrol file. And its code behind is : protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) { lcont1.my_tv_SelectedNodeChanged(sender, e); } } Now the usercontrol is: public

QT QItemSelectionModel to ignore columns?

别等时光非礼了梦想. 提交于 2019-12-02 08:05:06
I am trying to restrict selection of a tree to a particular column. I am using delegates heavily to create custom per-item-per-column behaviors, editors, etc. I was hoping I could somehow do this from a delegate by blocking an event or something similar. The problem is, I think i would have to create an entirely custom solution that mimics extended selection. However, after a lot of searching and very few examples, it sounds like I want a custom QItemSelectionModel on my tree view. Is this assumption correct? How do I create a custom QItemSelectionModel that will use the Extended Selection

How to expand top-level QTreeview items

两盒软妹~` 提交于 2019-12-01 11:54:12
问题 I do not understand why this does not seem to expand the top-level root items in a QTreeView: # clear existing treeview data model = self.treeview.model().sourceModel() model.clear() # add treeview items here # expand root level items root = model.invisibleRootItem() index = root.index() for i in range(root.rowCount()): item = model.indexFromItem(model.item(i,0)) self.treeview.expand(item) self.treeview.setExpanded(item, True) print 'expanded' 回答1: If you're using a proxy model, you must use