qlistwidget

How to undo an edit of a QListWidgetItem in PySide/PyQt?

Deadly 提交于 2019-12-17 21:10:45
问题 Short version How do you implement undo functionality for edits made on QListWidgetItems in PySide/PyQt? Hint from a Qt tutorial? The following tutorial written for Qt users (c++) likely has the answer, but I am not a c++ person, so get a bit lost: Using Undo/Redo with Item Views Longer version I am using a QListWidget to learn my way around PyQt's Undo Framework (with the help of an article on the topic). I am fine with undo/redo when I implement a command myself (like deleting an item from

QListWidget drag and drop items disappearing from list on Symbian

核能气质少年 提交于 2019-12-13 12:34:46
问题 I'm having trouble implementing a QListWidget with custom items that can be reordered by dragging and dropping. The problem is when I make a fast double click (a very short drag&drop) on an item, the item sometimes disappears from the QListWidget. This is the constructor for my Widget: ListPopisiDragDrop::ListPopisiDragDrop(QWidget *parent) : QListWidget(parent) { setSelectionMode(QAbstractItemView::SingleSelection); setDragEnabled(true); viewport()->setAcceptDrops(true); setDefaultDropAction

delete items from 3 different lists

僤鯓⒐⒋嵵緔 提交于 2019-12-13 05:06:25
问题 I need some help with deleting some items from some lists at the same time, when a button is clicked. This is the code: class Window(QMainWindow): list_1 = [] #The items are strings list_2 = [] #The items are strings def __init__(self): #A lot of stuff in here def fillLists(self): #I fill the lists list_1 and list_2 with this method def callAnotherClass(self): self.AnotherClass().exec_() #I do this to open a QDialog in a new window class AnotherClass(QDialog): def __init__(self): QDialog._

How to save and load QListWidjet contents to/from QSetting with PyQt4?

旧巷老猫 提交于 2019-12-13 04:12:12
问题 I've got a QListWidget in my PyQt4 app. It contains folders paths. I want to save its contents to QSettings and load them later. I used this code to do this: def foldersSave(self): folders = {} '''create dict to store data''' foldersnum = self.configDialog.FolderLIST.count() '''get number of items''' if foldersnum: for i in range(foldersnum): folders[i] = self.configDialog.FolderLIST.item(i).text() '''save items text to dict''' return str(folders) '''return string of folders to store in

Getting selected rows in QListWidget

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 11:39:43
问题 I have a Qlistwidget in which I can select multiple items. I can get a list with all the selected items in the listwidget but can not find a way to get a list of the corresponding rows. To get a list of the selected items in the listwidget I used the following code: print [str(x.text()) for x in self.listWidget.selectedItems()] To retrieve the rows I am looking for something like: a = self.listWidget.selectedIndexes() print a But this does not work. I have also tried some code which resulted

How to show icons without text in QListWidget?

*爱你&永不变心* 提交于 2019-12-12 10:56:24
问题 I want to show only icons in my QListWidget. I set text to empty string. When I select an icon I see an empty selected square on the text place. See the screenshot How can I get rid of this empty space?! 回答1: use NULL instead ui->listWidget->addItem(new QListWidgetItem(QIcon(":/res/icon"),NULL)); 回答2: How do you add an icon in your QListWidget? This should work fine (I am loading the icon from the resource file) : ui->listWidget->addItem(new QListWidgetItem(QIcon(":/res/icon"), "")); EDIT

Qt drag and drop between two QListWidget

老子叫甜甜 提交于 2019-12-12 09:36:49
问题 I've two QListWidget (list1 and list2) list1 should be able to receive items from list2 list1 should be able to be reorganized with an internal drag and drop list2 should be able to receive items from list1 list1->setSelectionMode(QAbstractItemView::SingleSelection); list1->setDragEnabled(true); list1->setDragDropMode(QAbstractItemView::DragDrop); list1->viewport()->setAcceptDrops(true); list1->setDropIndicatorShown(true); ulist2->setSelectionMode(QAbstractItemView::SingleSelection); list2-

How to get the checked items listed in a Qt QListWidget

大兔子大兔子 提交于 2019-12-12 07:27:59
问题 I've populated a QListWidget with a list of items and added a check box leaving everything unchecked. for td in root.iter('testdata'): test_data = td.get('ins') item = QtGui.QListWidgetItem(test_data, self.listWidgetLabels) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) item.setCheckState(QtCore.Qt.Unchecked) The user then clicks a few of the items in the QListItem and clicks a 'Generate File' button on the gui. self.pushButtonGenerateFile.clicked.connect(self.generate_file) I

How can fetch the row which has been recently added in the qlistwidget

余生颓废 提交于 2019-12-12 02:15:14
问题 How to fetch the last inserted item. An example QSqlQuery qry; qry.prepare("SELECT * FROM users"); qry.exec(); while(qry.next()){ ui->listWidget->addItem(qry.value("username").toString()); } As you seen in the previous example specifically this line ui->listWidget->addItem(qry.value("username").toString()); This line to add every database row in as an item in qlistwidget. I have tried to use the following but does not work . QSqlQuery qry; qry.prepare("SELECT * FROM users"); qry.exec(); while

Qt Command Log using QListWidget

拈花ヽ惹草 提交于 2019-12-11 15:23:41
问题 I am trying to build a command log on a user interface. Meaning, when the user click a button, check a box, upload some images etc, basically every time the user interacts with the user interface the action is recorded inside a QListWidget Command Log shown below. Basically this is how the ui looks as soon as the user run it: And this is what I am try to achieve everytime the user interacts with the ui: Below snippets of code from the constructor: mainwindow.h private: QListWidget