qlistview

QListView selection with highlight/hover

天大地大妈咪最大 提交于 2019-12-22 12:09:09
问题 How to do item in QListView selected as I would click on him? Way I tried to do this I have selection but like not-active one. Without Blue highlight only grey one. To be mroe detailed: Make QListView AddSomeItems Run app Move mouse to any item Select it Now its, selected and ALSO blue. This is what I want to do with item before I run application. If it is possible of course. (selectable + hover + focus?) I want to have it without clicking I tried many ways: view->clicked(selectedIndex); view

How do I tell QListView to resize to fit?

一笑奈何 提交于 2019-12-20 04:48:04
问题 I have a QListView and have assigned a model and a delegate. I am using it to display images in a horizontal bar as below On a user event, data is updated in the model. One such event causes the width of the images to be reduced like below(#4). I emit a dataChanged on the corresponding index and only the concerned widget is repainted. Because of this, there is a gap between #4 and #5 which does not get filled. I am thinking that there must be a way to refresh all visible rows - but am unable

How do I tell QListView to resize to fit?

我们两清 提交于 2019-12-20 04:47:24
问题 I have a QListView and have assigned a model and a delegate. I am using it to display images in a horizontal bar as below On a user event, data is updated in the model. One such event causes the width of the images to be reduced like below(#4). I emit a dataChanged on the corresponding index and only the concerned widget is repainted. Because of this, there is a gap between #4 and #5 which does not get filled. I am thinking that there must be a way to refresh all visible rows - but am unable

How to change the color of QStringListModel items?

让人想犯罪 __ 提交于 2019-12-19 02:29:11
问题 I have QListView *myListView; QStringList *myStringList; QStringListModel *myListModel; which I fill with data like this: myStringList->append(QString::fromStdString(...)); myListModel->setStringList(*myStringList); myListView->setModel(myListModel); I want to change the font-color of some list entries, so I tried: for (int i = 0; i < myListModel->rowCount(); ++i) { std::cerr << myListModel->index(i).data().toString().toStdString() << std::endl; myListModel->setData(myListModel->index(i),

loading data from database to expose in qml

北慕城南 提交于 2019-12-13 02:27:09
问题 I am new to QML, so please forgive my lack of knowledge. I am loading some data from my database - after clicking in a button - and I want to fill a ListView with it. This is my ListView: Rectangle { id:tblKules anchors.horizontalCenter: parent.horizontalCenter width: menuListaItem.width height:300 visible:false color: "#e5e6e8" ListView { id: listView anchors.fill: parent; anchors.margins: 5 model: mainController.listaDispositivos spacing: 1 delegate: Component { Rectangle { id:item width:

Catch which mousebutton is pressed on item

我与影子孤独终老i 提交于 2019-12-12 02:29:02
问题 I have a UI.py file with the mainWindow class definition (build with Qt Designer and Pyside). The UI is imported in the main module. In the Ui I have a listbox. Based on the left or right mouse clicked on an item a procedure must be executed, e.g leftMouseClicked and rightMouseClicked. Thanks for your help. 回答1: you can define a mousePressEvent() method in your QListWidget subclass to handle mouse press event. Get which button is clicked by the event parameter and save it to an attribute.

Get selected files' filenames from PYQT5 QListview in python

我的梦境 提交于 2019-12-12 01:16:09
问题 I am having trouble retrieving the filenames from selected QListview, I want the get the names of the files I selected from my list so that I can open the files by calling the filenames I retrieved. However, this doesn't work... Also, how do I set a multi select mode and retrieve all the files' filenames selected?? from PyQt5 import QtCore, QtGui, QtWidgets import PandasModel import pandas as pd class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow")

How to change color of item in QListView

落花浮王杯 提交于 2019-12-11 12:09:55
问题 I have my own subclass of QListView and I would like to change the color of an item with index mLastIndex . I tried with QModelIndex vIndex = model()->index(mLastIndex,0) ; QMap<int,QVariant> vMap; vMap.insert(Qt::ForegroundRole, QVariant(QBrush(Qt::red))) ; model()->setItemData(vIndex, vMap) ; But it didn't change the color, instead, the item wasn't displayed anymore. Any idea about what was wrong? 回答1: Your code are simply clear all data in model and leaves only value for Qt::ForegroundRole

Qt: List of (custom) QWidgets without performance problems

被刻印的时光 ゝ 提交于 2019-12-11 09:53:10
问题 I'm right now creating an Qt-application and have following problem: I designed a custom QWidget with some labels and checkboxes. The application should now show a list of the custom QWidgets. I tried the QListWidget but is very slow for my use case. I want to add over 6000 elements of my custom QWidget. If I create these instances of the element and add it to the QListWidget the application will crashed. Which is the best approach for my issue? Thanks a lot! 回答1: As others have noted,

PySide2 QListView QTableView sync problem

▼魔方 西西 提交于 2019-12-11 07:45:13
问题 It is python/PySide2 interface related problem, as much as I tried, I couldn't make it sync (QListView and QTableView). I will try to simplify it, instead of explaining the whole complicated thing which is much bigger with full of forms stuff in QT... Just imagine to have a data structure (I guess, model) like the following: dict_of_dicts={ 'dict1':{'k1':'v1', 'k2':'v2', 'k3':'v3'}, 'dict2':{'k4':'v4'}, 'dict3':{'k5':'v5', 'k6':'v6', 'k7':'v7'}, } I would like to have a form (or dialog), with