qlabel

Which QLabel was pressed by mousePressEvent

寵の児 提交于 2020-08-19 09:08:39
问题 How can I get in method on_product_clicked where QLabel is a mousePressEvent ? In the current example I see three images in the form. When I click the second image I need to have number 2 in the on_product_clicked method. product_images = ['first_icon.png', 'second_icon.png', 'third_icon.png'] self.vbox_choice_img = QHBoxLayout() for image in product_images: label = QLabel() pixmap = QtGui.QPixmap(image) pixmap = pixmap.scaled(250, 250) label.setPixmap(pixmap) label.setAlignment(QtCore.Qt

Mouseover event for a PyQT5 Label

拥有回忆 提交于 2020-06-27 11:55:25
问题 I am a newbie to python i want that if i move my mouse over the label with text stop on it then it should change the value of a variable Stop to True so that i may pause/Stop ,my program. i have looked the code at Mouseover event filter for a PyQT Label and tried to run it but nothing is being shown up Please guide me... the code is as under from PyQt5.QtWidgets import * from PyQt5.QtGui import * from PyQt5.QtCore import * from PyQt5 import * import sys class mouseoverEvent(QtCore.QObject):

QLabel not giving updated txt

混江龙づ霸主 提交于 2020-06-23 18:04:10
问题 I added a QLabel inside my widget and it is editable through UI, able to set new text also, but not able to retrieve the updated text using function text(); QLabel *m_ColorName = new QLabel("_________"); m_ColorName->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextEditable); In UI i am able to edit to new text but by calling function m_ColorName->text(); Its giving default txt _________ Code H file class CascadeColorHighlightWidgetItem : public QWidget { Q_OBJECT public:

Remove an Image in QLabel After Button Clicked

只谈情不闲聊 提交于 2020-01-30 08:34:14
问题 I have qlabels that displaying images . I want to delete image if user clicks remove button . I can learn which image clicked labels[i].mousePressEvent = functools.partial(self.remove_image, source_label = labels[i] ,source_image = pixmap) but i couldn't use it and connects with button . How can i remove image ? 回答1: Assuming labels[] has a list of label s ID, I think you can do something like: labels[i].mousePressEvent = functools.partial(self.remove_image, source_label = labels[i]) #just

“text-overflow” for a QLabel’s text rendering in QT

大城市里の小女人 提交于 2020-01-22 06:57:50
问题 I have got a QLabel element in a widget which can be resized. The text can overflow boundaries, so I need, for the application to look more elegant, some way to make the text generate an ellipsis (...) after the last totally visible word in the text. Making layouts in HTML/CSS I used to use text-overflow: ellipsis; for this, but for QT classes I have not found any information on this. 回答1: It looks like on your label resize event you can create elided text using the new width of the widget

“text-overflow” for a QLabel’s text rendering in QT

北战南征 提交于 2020-01-22 06:54:31
问题 I have got a QLabel element in a widget which can be resized. The text can overflow boundaries, so I need, for the application to look more elegant, some way to make the text generate an ellipsis (...) after the last totally visible word in the text. Making layouts in HTML/CSS I used to use text-overflow: ellipsis; for this, but for QT classes I have not found any information on this. 回答1: It looks like on your label resize event you can create elided text using the new width of the widget

Displaying gif in PyQt GUI using QLabel

守給你的承諾、 提交于 2020-01-11 12:17:13
问题 I am trying to display a loading gif after a button is pressed. This is the code I currently have import sys from PyQt4 import QtGui, QtCore from PyQt4.QtCore import * from PyQt4.QtGui import * class MainWindow (QtGui.QMainWindow): def __init__(self, parent=None): super(MainWindow,self).__init__(parent) self.setGeometry(50,50,240,320) self.home() def home(self): but = QtGui.QPushButton("Example", self)#Creates the brew coffee button but.clicked.connect(self.gif_display) but.resize(200,80) but

Displaying gif in PyQt GUI using QLabel

烂漫一生 提交于 2020-01-11 12:17:11
问题 I am trying to display a loading gif after a button is pressed. This is the code I currently have import sys from PyQt4 import QtGui, QtCore from PyQt4.QtCore import * from PyQt4.QtGui import * class MainWindow (QtGui.QMainWindow): def __init__(self, parent=None): super(MainWindow,self).__init__(parent) self.setGeometry(50,50,240,320) self.home() def home(self): but = QtGui.QPushButton("Example", self)#Creates the brew coffee button but.clicked.connect(self.gif_display) but.resize(200,80) but

Displaying an image in QLabel

≯℡__Kan透↙ 提交于 2020-01-06 08:51:09
问题 I have created a Qt interface, add a Qlabel and set pixmap to an image. imagelabel = new QLabel(centralwidget); imagelabel->setObjectName(QString::fromUtf8("imagelabel")); imagelabel->setGeometry(QRect(20, 10, 371, 311)); imagelabel->setPixmap(QPixmap(QString::fromUtf8(":/liqi/kinect.png"))); this is the code displayed in ui_mainwindow.h when i preview it using the Qtdesigner, the image can be displayed. But when i run using codeblocks, everything like buttons etc is fine but the image does

Displaying an image in QLabel

瘦欲@ 提交于 2020-01-06 08:51:06
问题 I have created a Qt interface, add a Qlabel and set pixmap to an image. imagelabel = new QLabel(centralwidget); imagelabel->setObjectName(QString::fromUtf8("imagelabel")); imagelabel->setGeometry(QRect(20, 10, 371, 311)); imagelabel->setPixmap(QPixmap(QString::fromUtf8(":/liqi/kinect.png"))); this is the code displayed in ui_mainwindow.h when i preview it using the Qtdesigner, the image can be displayed. But when i run using codeblocks, everything like buttons etc is fine but the image does