qlistwidget

How QRegularExpression can be passed to Qt::MatchRegularExpression

时间秒杀一切 提交于 2021-02-11 14:18:32
问题 I am trying this sample code that I found which is really really good. I am also trying to figure out the same thing to find an item and scroll to it, but this time I wanted to match the the string which has the EXACT WORD "cat" . Example matches: cat tom cat dog and cat super cat To make it very simple I am just trying to match an exact word in a string. Take this sample code as an example: import re s= "1 tom cat" s2 = "2 thundercat" if re.search(r'\bcat\b',s2): print("There is an EXACT

C++ - QListWidget select first item

落花浮王杯 提交于 2021-02-11 04:33:55
问题 In my QMainWindow Constructor I read a database and fill my QListWidget with the items. Apparently there is no item selected so I have to do it on my own. I also have a slot which will be called when I click on an item in the list. I tried setCurrentRow( const int ) but if I do so the slot won't be called. I've seen the function setCurrentIndex( const QModelIndex & ) but I'm not familiar with the QModelIndex. How do I tell my QListWidget to select the first item and call the on_list_clicked

C++ - QListWidget select first item

北慕城南 提交于 2021-02-11 04:33:45
问题 In my QMainWindow Constructor I read a database and fill my QListWidget with the items. Apparently there is no item selected so I have to do it on my own. I also have a slot which will be called when I click on an item in the list. I tried setCurrentRow( const int ) but if I do so the slot won't be called. I've seen the function setCurrentIndex( const QModelIndex & ) but I'm not familiar with the QModelIndex. How do I tell my QListWidget to select the first item and call the on_list_clicked

C++ - QListWidget select first item

回眸只為那壹抹淺笑 提交于 2021-02-11 04:30:51
问题 In my QMainWindow Constructor I read a database and fill my QListWidget with the items. Apparently there is no item selected so I have to do it on my own. I also have a slot which will be called when I click on an item in the list. I tried setCurrentRow( const int ) but if I do so the slot won't be called. I've seen the function setCurrentIndex( const QModelIndex & ) but I'm not familiar with the QModelIndex. How do I tell my QListWidget to select the first item and call the on_list_clicked

C++ - QListWidget select first item

我的梦境 提交于 2021-02-11 04:30:24
问题 In my QMainWindow Constructor I read a database and fill my QListWidget with the items. Apparently there is no item selected so I have to do it on my own. I also have a slot which will be called when I click on an item in the list. I tried setCurrentRow( const int ) but if I do so the slot won't be called. I've seen the function setCurrentIndex( const QModelIndex & ) but I'm not familiar with the QModelIndex. How do I tell my QListWidget to select the first item and call the on_list_clicked

C++ - QListWidget select first item

瘦欲@ 提交于 2021-02-11 04:30:13
问题 In my QMainWindow Constructor I read a database and fill my QListWidget with the items. Apparently there is no item selected so I have to do it on my own. I also have a slot which will be called when I click on an item in the list. I tried setCurrentRow( const int ) but if I do so the slot won't be called. I've seen the function setCurrentIndex( const QModelIndex & ) but I'm not familiar with the QModelIndex. How do I tell my QListWidget to select the first item and call the on_list_clicked

would like not clickable/highlighted icons in listWidget

﹥>﹥吖頭↗ 提交于 2021-02-05 08:08:54
问题 I have QListWidget in Pyside2 that has icons populating it. I dont like the icons taking on a shaded grey look when the mouse clicks them. Is there a way to disable this action? I will include a picture. 回答1: You have to use a delegate that disables the QStyle::State_Selected flag: from PySide2 import QtCore, QtGui, QtWidgets class StyledItemDelegate(QtWidgets.QStyledItemDelegate): def initStyleOption(self, option, index): option.state &= ~QtWidgets.QStyle.State_Selected super

would like not clickable/highlighted icons in listWidget

房东的猫 提交于 2021-02-05 08:07:03
问题 I have QListWidget in Pyside2 that has icons populating it. I dont like the icons taking on a shaded grey look when the mouse clicks them. Is there a way to disable this action? I will include a picture. 回答1: You have to use a delegate that disables the QStyle::State_Selected flag: from PySide2 import QtCore, QtGui, QtWidgets class StyledItemDelegate(QtWidgets.QStyledItemDelegate): def initStyleOption(self, option, index): option.state &= ~QtWidgets.QStyle.State_Selected super

Adding items to QlistView

↘锁芯ラ 提交于 2021-02-04 14:58:08
问题 I'm using pyqt4 with python 2.7 and I have a list view widget that I can't add items to it # -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'add_category.ui' # # Created: Mon Mar 19 23:22:30 2018 # by: PyQt4 UI code generator 4.10 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: def _fromUtf8(s): return s try: _encoding = QtGui.QApplication.UnicodeUTF8 def

QStyledItemDelegate truncates text horizontally and doesn't add a horizontal scroll bar

混江龙づ霸主 提交于 2021-01-28 19:08:29
问题 I got the following code, which I slightly modified, as an answer on how to use HTML formatted text in a QListWidget. main.ui <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>Dialog</class> <widget class="QDialog" name="Dialog"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>341</width> <height>161</height> </rect> </property> <property name="windowTitle"> <string>Dialog</string> </property> <widget class="QWidget" name="verticalLayoutWidget"> <property name=