qlistwidget

PySide: Drag and drop files into QListWidget

风格不统一 提交于 2020-02-20 10:39:24
问题 This is my first entry here so apologies for any newbie mistakes. I've searched both here and Google with no luck before posting. I want to be able to add images to a QListWidget, using drag and drop from a file browser. Dropping a valid file on the list widget also needs to trigger a function in the main class of my app, and pass it the image path. I found this code that does exactly that, but for PyQt4. Importing QtCore and QtGui from PySide instead of PyQt4 produces a segmentation fault

PySide: Drag and drop files into QListWidget

ε祈祈猫儿з 提交于 2020-02-20 10:38:00
问题 This is my first entry here so apologies for any newbie mistakes. I've searched both here and Google with no luck before posting. I want to be able to add images to a QListWidget, using drag and drop from a file browser. Dropping a valid file on the list widget also needs to trigger a function in the main class of my app, and pass it the image path. I found this code that does exactly that, but for PyQt4. Importing QtCore and QtGui from PySide instead of PyQt4 produces a segmentation fault

PySide: Drag and drop files into QListWidget

主宰稳场 提交于 2020-02-20 10:37:46
问题 This is my first entry here so apologies for any newbie mistakes. I've searched both here and Google with no luck before posting. I want to be able to add images to a QListWidget, using drag and drop from a file browser. Dropping a valid file on the list widget also needs to trigger a function in the main class of my app, and pass it the image path. I found this code that does exactly that, but for PyQt4. Importing QtCore and QtGui from PySide instead of PyQt4 produces a segmentation fault

multiple fonts in one line of a QListWidget

可紊 提交于 2020-01-24 21:54:46
问题 I need to include text and greek symbols (for simple mathematical equations) in the different options proposed by a QListWidget in a '.ui' file (I use to work with Qt Designer and I like python if it matters). I want the options to appear like this: theta = phi^2 (toto et al.) theta = phi^2.5 (tata et al.) theta = 1-log(phi/2) (mister brown et al.) ... with 'theta' and 'phi' replaced by their symbol. Strangely, this turns out to be not so simple... How to define several fonts in one line of a

Moving items up and down in a QListWidget?

这一生的挚爱 提交于 2020-01-15 08:22:07
问题 In a QListWidget I have a set of entries. Now I want to allow the user to sort (reorder) these entries through two buttons (Up/Down). Here's part of my code: def __init__(self): QtGui.QMainWindow.__init__(self) self.ventana = Ui_MainWindow() self.ventana.setupUi(self) self.connect(self.ventana.btExit, QtCore.SIGNAL('clicked()'), QtCore.SLOT('close()')) self.connect(self.ventana.btAdd, QtCore.SIGNAL('clicked()'), self.addButton) self.connect(self.ventana.btQuit, QtCore.SIGNAL('clicked()'),

Selected QListWidgetItem without changing text color

旧街凉风 提交于 2020-01-07 08:27:19
问题 I've got qListWidget with some items which have different text colors. I want to change background color of selected item without touching color of text. I tried with styleSheet but then all selected items has same colors. It is posible to select item without changing color of the text? 回答1: Try to use item->setData(Qt::BackgroundRole, QBrush(color)); . 来源: https://stackoverflow.com/questions/18035707/selected-qlistwidgetitem-without-changing-text-color

QListWidget

北战南征 提交于 2020-01-03 23:09:11
QListWidget使用: Widget::Widget(QWidget *parent) : QWidget(parent) , ui(new Ui::Widget) { ui->setupUi(this); //插入数据的集中方法 ui->listWidget->clear(); //清空连表控件 QListWidgetItem *Item1=new QListWidgetItem ; //针对每一行操作 Item1->setText("测试数据1"); ui->listWidget->insertItem(0,Item1); new QListWidgetItem("test item2",ui->listWidget); ui->listWidget->addItem("test item3"); //插入包含图标的数据 QListWidgetItem *itemIcon=new QListWidgetItem; itemIcon->setText("test item icon4"); itemIcon->setIcon(QIcon("1.png"));//debug 为当前工作目录 ui->listWidget->addItem(itemIcon); //遍历列表 for(int i=0;i<ui->listWidget->count();i++) { qDebug(

PyQt5 ListWidget add list items

怎甘沉沦 提交于 2020-01-03 19:40:30
问题 while learning PyQt5 i found a little problem( maybe a bug) in the ListWidget Widget (and all other widgets) the ListWidget have a addItem method overloaded : ( the code is in c++ but this is the same interface in pyqt ) void addItem(const QString &label) void addItem(QListWidgetItem *item) void addItems(const QStringList &labels) so the problem is that in PyQt5 there is no more QStringList type, and i should use a simple list of strings instead of the QStringList but when i receive and error

Drag'N'Drop custom widget items between QListWidgets

China☆狼群 提交于 2020-01-02 08:53:28
问题 i am currently working on a Python program, where i want to move items from one QListWidget to another with Drag and Drop. i read this thread, and implemented the Drag and Drop as described. It works with standard QListWidgetItems. The Problem is, i wanna do this custom widgets inside the QListWidgetItems, as described here, to store an icon and several lines into 1 QListWidgetItem. So when i now drag and drop an item into another list, it is empty, because it seems just to move/copy the

Can't change state of checkable QListViewItem with custom widget

流过昼夜 提交于 2020-01-02 04:06:08
问题 I have a QListWidget where I want to add a bunch of items with a custom widget: listWidget = QListWidget() item = QListWidgetItem() item.setFlags(item.flags() | Qt.ItemIsUserCheckable) item.setCheckState(Qt.Unchecked) listWidget.addItem(item) widget = MyLabelAndPushButton() item.setSizeHint(widget.sizeHint()) listWidget.setItemWidget(item, widget) As the name suggests MyLabelAndPushButton is just a widget containing a QLabel and a QPushButton in a layout. The problem is that I can not use the