qtreeview

Is there a bug in my code for populating a QTreeView?

I'm using PyQt 4.4. It's best shown using some pictures. All nodes should have leafs from 0 to 99. They are being incrementally loaded using canFetchMore() and fetchMore(). But for some reason unknown for me this works only for the root node. (Picture 1) If I collapse and expand a node it loads additional 10 values. (Picture 2 & 3) It...

Updating a QListView when objects change externally

Hi, I've a simple question regarding the update of a QTreeView (or any subclass of QAbstractItemView) when a model object changes externally. Let's say that a list shows a subclass of QAbstractItemModel, and an item of that model gets changed outside of the list window, and we would like to update the list with the change. What is the u...

Custom text color for certain indexes in QTreeView

I would like to draw texts in one of the columns in a QTreeView widget using a custom color (depending on the data related to each row). I tried to overload the drawRow() protected method and change the style option parameter like this (a stripped-down example): virtual void drawRow(QPainter* p_painter, const QStyleOptionViewItem& optio...

Most elegant/safe/easy solution to store and edit (GUI) a directory-like tree structure?

Hello, I've got a slightly tricky problem to solve; imagine this: One of my applications needs to make heavy use of scripting, so my idea was to provide the user a way to write script snippets and organize them in a directory-like tree structure. This is much like a source code directories with subdirectories and source files. Data Cl...

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

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 mod...

Adding Vertical headers to a QTreeView

I have a QTreeView subclass (and QAbstractItemModel subclass) which has a nice horizontal header. I would like to add vertical headers (going down the left side) to match. But unlike QTableView which has separate vertical (setVerticalHeader()) and horizontal headers (setHorizontalHeader()), QTreeView only allows a single header (setHeade...

How to get details about the selected items using QTreeView?

Hello, I'm using QTreeView with QDirModel like this: QDirModel * model = new QDirModel; ui->treeView->setModel(model); ui->treeView->setSelectionMode(QTreeView::ExtendedSelection); ui->treeView->setSelectionBehavior(QTreeView::SelectRows); This works fine, however, I'm not sure how to get the details about the files I select. I've got...

How to create artificial nodes in QAbstractItemModel for QTreeView

Hi, my question is about Qt and its QAbstractItemModel. I have a map of strings and doubles (std::map<stringclass, double>) which I would like to present in a Qt widget. While I could use QTableView for that, I would like to exploit the fact that the keys of the map are of form "abc.def.ghi" where there can be multiple strings that c...

How can I have two vertical header in a QTreeview?

I want the top header to span on 2 or 3 bottom header column. Is there a way to do so in Qt c++? I'm looking for an exemple. thank you. ...

Stop single QModelIndex from being update

I have a QTreeView with data that changes over time, with a dataChanged signal being emitted in the QAbstractItemModel every second. The items in the QTreeView can be edited as well, but when a editor is opened for a certain item the editor string is updated while I edit is, which is very annoying. Any way to prevent an editor to be upda...

QT: I've inherited from QTreeView. I've inherited from QStandardItem. How do i Style the items?

My Google skills must be failing me today. I've inherited from QTreeView to create a TreeView that stores a QStandardItemModel instead of a QAbstractItemModel. I have also inherited from QStandardItem to create a class to store my data in an item as is necessary. I've successfully inserted my derived QStandardItem into my derived QTree...

PyQt: How to keep QTreeView nodes correctly expanded after a sort

I'm writing a simple test program using QTreeModel and QTreeView for a more complex project later on. In this simple program, I have data in groups which may be contracted or expanded, as one would expect in a QTreeView. The data may also be sorted by the various data columns (QTreeView.setSortingEnabled is True). Each tree item is a lis...

Right clicking on QHeaderView inside of QTreeView

I've written a descendant of QTreeView with multiple columns. I want to create a popup menu that appears whe nthe user right-clicks over the column headers. I have tried catching signals from QTreeView for this, but QTreeView doesn't seem to emit signals on the headers. QTreeView.header() does. I therefore believe I must either: 1: conne...

Set bold rows in a QTreeView

I have a custom subclass of a QTreeView in a pyqt application. I'm trying to give the user the ability to highlight and "lowlight" (for lack of a better term) rows. Highlighted rows should have bold text and (optionally) a different background color. Any ideas? I'm considering StyleSheets as an option, but have so far been unable to get ...

Is it possible to deselect in a QTreeView by clicking off an item?

I'd like to be able to deselect items in my QTreeView by clicking in a part of the QTreeView with no items in, but I can't seem to find anyway of doing this. I'd intercept a click that's not on an item, but the QTreeView doesn't have a clicked signal, so I can't work out how to do this. ...

QTreeView memory consumption

Hello. I'm testing QTreeView functionality right now, and i was amazed by one thing. It seems that QTreeView memory consumption depends on items count O_O. This is highly unusual, since model-view containers of such type only keeps track for items being displayed, and rest of items are in the model. I have written a following code with ...

HowTo restore QTreeView last expanded state?

Hi. What I have: QTreeView class with table data And connected QAbstractTableModel model Question: how to save expanded state of items? Is some one have finished solutions? PS: I know, that I can do this code by myself, but I don't have much time, and this is not the major problem of our project, but still we need it, because app ...

QFileDialog for directories that have certain content

I would like to build a dialog similar to QFileDialog::getExistingDirectory() for which the OK-button only is enabled when the selected directory contains certain files. I know I cannot achieve this with QFileDialog, instead I would have to come up with my own QDialog that has a QTreeView coupled to a QFileSystemModel. How can I limit...

Qtreeview, resizing a line when it's been selected

Hey all, I'm using Qt 4.7.0, a Qtreeview with multiple columns. What I want to do is "simple" : I want a line to increase its height, when it's selected. Will delegates be enough to do this ? I've been through some stuff with a QTableView : m_pMyTableView->verticalHeader()->setResizeMode(QHeaderView::Interactive); ... QSize Abstrac...

background color for certain items(rows) in QFileSystemModel QTreeView

How do i set a custom background color for certain rows in a QFileSystemModel applied on a QTreeView? ...