Questions tagged [qstandarditem]

The QStandardItem class provides an item for use with the QStandardItemModel class. Items usually contain text, icons, or checkboxes.

The QStandardItem class provides an item for use with the QStandardItemModel class. Items usually contain text, icons, or checkboxes.

Each item can have its own background brush which is set with the setBackground() function. The current background brush can be found with background(). The text label for each item can be rendered with its own font and brush. These are specified with the setFont() and setForeground() functions, and read with font() and foreground().

By default, items are enabled, editable, selectable, checkable, and can be used both as the source of a drag and drop operation and as a drop target. Each item's flags can be changed by calling setFlags(). Checkable items can be checked and unchecked with the setCheckState() function. The corresponding checkState() function indicates whether the item is currently checked.

Documentation for Qt 4.8 and for Qt 5.

67 questions
1
vote
1 answer

Preserve QStandardItem subclasses in drag and drop

I have: self.treeView = QTreeView() self.treeView.setObjectName("testView") self.treeView.setDragDropMode(QAbstractItemView.InternalMove) self.treeView.setSelectionMode(QAbstractItemView.ExtendedSelection) itemA = SubclassQStandardItemA(self) itemB…
Dariusz
  • 960
  • 13
  • 36
1
vote
1 answer

Renaming QTreeView Items

I have been looking around for quite a while now and I haven't been able to find a solution for trying to Rename items in a QTreeView. Basically what I mean by this is when you double click something in the QTreeView you get the option of renaming…
user3427150
  • 13
  • 1
  • 4
1
vote
2 answers

QListView item with checkbox selection behavior

I'm adding checkbox items to a list view. Then when I change the check box indicator, the item row is not selected. And when I'm selection an item in the list, the check box indicator won't change. The checkbox indicator should be…
Simon
  • 1,522
  • 2
  • 12
  • 24
1
vote
1 answer

How to populate a QListView with value and display data?

I'm doing a form that contains a QListView. It's populated from database with this code: model = QStandardItemModel(self.listUser) for row in self.SELECT_USERS_ACCOUNTS(): item = QStandardItem(str(row[1])) …
GSandro_Strongs
  • 773
  • 3
  • 11
  • 24
1
vote
2 answers

cannot convert 'QScopedPointer' to 'QStandardItem *'

I use this code without any error QStandardItem *newRow; newRow = new QStandardItem(hostname); model2->setItem(index, 2, newRow); I want to change the above code to the below: QScopedPointer newRow(new…
1
vote
1 answer

Deleting QStandardItems from QStandardItemModel

I am trying to delete QStandardItems from QStandrditemModel using QPersistentIndex. Items are successfully deleted, but when iterate through the model the deleted rows appear without any data. I am using the following code to delete the…
user1703942
  • 317
  • 3
  • 15
1
vote
3 answers

Track QStandardItem lifetime

I'm writing some wrappers over QStandardItemModel. Is it possible to track lifetime (delete events) of QStandardItems? I think that the only way is to interhit QObject + QStandardItem. But I don't want to do it for some reasons. UPDATE: I need to…
Dmitry Sazonov
  • 8,801
  • 1
  • 35
  • 61
0
votes
0 answers

using a QItemDelegate subclass to get old and new data in a signal

I have a QTableView backed by a QStandardItemModel. The table also supports editing. One of the columns in this table contains a user editable QString. If the data changes, I need to know both the old and new QVariant values through a Qt signal. I…
johnco3
  • 2,401
  • 4
  • 35
  • 67
0
votes
0 answers

PyQT5 - Custom QListView with reordering posibilities

I extensively used topic on SO but never posted anything so excuse me if I made mistakes. So, my goal is too create a PyQT5 GUI with a QListView displaying layers for a plotly Dash server. To be completed I need a contextual menu (Done) and the…
0
votes
0 answers

How to make custom QStandardItem for QTreeView?

In my project there is a window for editing files. Each file has some properties that the user can change with several checkboxes. Also each file has an icon. Now it is implemented through QScrollArea in which widgets are added. It looks like…
9ft6
  • 1
  • 1
0
votes
0 answers

Move forward and backwards between Items in QTreeView

I have a QTreeView with a QStandardItemModel and QStandardItems. I want to add buttons that lead from one element to the next or to the previous element. Getting the index from the current element works, but how to get the index from the next one or…
Mazze
  • 383
  • 3
  • 13
0
votes
0 answers

How can I make QStandardItems in a QTreeView work like buttons opening a new window (submenu)?

I am fairly new to PyQt5 or rather to Qt in general, so sorry if this question is really dumb or basic. I am assigned working on an application for some rather complex scientific data analysis that uses PyQt5. Now my current task is to create an…
0
votes
1 answer

How to reproduce the same operations (Copy, Paste, ...) on different items of a Qt Model/View?

I have a custom QTreeView and I fill it with custom QStandardItems. The model is a classic QStandardItemModel. I would like to have the possibility to have the same item repeated in the Tree. This means that if I change some properties of the item…
0
votes
1 answer

After adding row to a parent node, modify parent to show number of children below

I'm looping through my data, using addrow to either the root node or to parent off it (etc.). Now for the parent how to modify the 2nd cell in the parent to show the current number of children, then update that cell, as I add more children?
Jonn Doe
  • 31
  • 1
  • 1
  • 6
0
votes
1 answer

Set a QStandartItem as Expandable without having a child item

i am trying to send a folder structure between two differnt programs which can be on different computers. On my server I have a QFileSystemModel and on my client I have a QTreeView which has a QStandardItemModel as a model. And i have a prebuild…
Maitai
  • 42
  • 1
  • 10