qlabel

QPixmap maintain aspect ratio

♀尐吖头ヾ 提交于 2019-11-29 23:30:27
问题 I'm writing a program that will allow me to upload photos to TUMBLR via their API, I've got the uploading working (thanks to you guys). I've put a 'queueBox' on the side of the GUI, which displays the image names, and they are stored in a QListWidget. I've put this in my Main Class' constructor: def __init__(self): QtGui.QMainWindow.__init__(self) self.setupUi(self) self.queueBox.itemClicked.connect(self.displayPhoto) and I have this method: def displayPhoto(self, item): tempName = (item.text

Subclassing QLabel to show native 'Mouse Hover Button indicator'

半城伤御伤魂 提交于 2019-11-29 22:55:21
问题 I have a QLabel with a 'StyledPanel, raised' frame. It is clickable, by subclassing QLabel; class InteractiveLabel(QtGui.QLabel): def __init__(self, parent): QtGui.QLabel.__init__(self, parent) def mouseReleaseEvent(self, event): self.emit(QtCore.SIGNAL('clicked()')) However, a general opinion is that this 'Box' is not easily recognised as clickable. In an effort toward usability, I'd like the 'Box' to show it is clickable when the mouse is hovered over it. Obviously a reaction to a mouse

Insert clickable link in QLabel and detect click on this link to provoke an action

自作多情 提交于 2019-11-29 17:19:31
问题 I would like to handle a click to the link in this application of mine: When I click on the "Output File" link, I would like to be able to generate an action in my application. As of today, the link is described like this in the rich text QLabel: <a href="http://google.fr"><span style=" text-decoration: underline; color:#0000ff;">Output File"</span></a> (generated by Qt Designer) When clicked, it will open the default web browser to go to Google. That's not what I want; I'd like something

how to show picture and text in a label (PyQt)

爷,独闯天下 提交于 2019-11-29 12:59:06
I need to show a picture and text in a label, and this is my code: import sys from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * class MyLabel(QLabel): def __init__(self): super(MyLabel, self).__init__() def paintEvent(self, QPaintEvent): pos = QPoint(50, 50) painter = QPainter(self) painter.drawText(pos, 'hello,world') painter.setPen(QColor(255, 255, 255)) class Window(QWidget): def __init__(self): super(Window, self).__init__() layout = QHBoxLayout(self) self.label = MyLabel() self.pixmap = QPixmap('icon.png') self.label.setPixmap(self.pixmap) layout.addWidget

QLabel auto multiple lines

女生的网名这么多〃 提交于 2019-11-29 02:48:50
For example, we have a QLabel with MaximumWidth set to 400. When we try to display some text with pixel width more than 400, it's shown cut off. Is there any way to make QLabel display this string in multiple lines without using QFontMetrics or the like? s4eed If I understood your question correctly, you should use the setWordWrap function for your label, with true as its parameter. QLabel lbl("long long string"); lbl.setWordWrap(true); In order to show multiple lines in QLabel, right click on QLabel and select 'change rich text'. This brings up dialog where you can type the text as you want

How to make the text fill all the QLabel's space?

社会主义新天地 提交于 2019-11-28 13:06:39
I am working on a PyQt5 project, but would be happy to read C++/Qt answer as well, because C++ solutions may work on Python too. I have a MainWindow with a horizontal layout, and a QLabel in it. My QLabel's size Policy is "Expanding", therefore all my window is filled by the QLabel. However, the text displayed by my QLabel does not change its size. I would like the text to grow when the window grows, and be as big as possible, in the limit of the QLabel size. I have heard of QWidget::adjustSize() but could not figure out how to use it. The option scaledContents for my QLabel on QtDesigner does

QLabel: set color of text and background

混江龙づ霸主 提交于 2019-11-27 17:21:38
How do I set color of text and background of a QLabel ? Jérôme The best and recommended way is to use Qt Style Sheet . To change the text color and background color of a QLabel , here is what I would do : QLabel* pLabel = new QLabel; pLabel->setStyleSheet("QLabel { background-color : red; color : blue; }"); You could also avoid using Qt Style Sheets and change the QPalette colors of your QLabel , but you might get different results on different platforms and/or styles. As Qt documentation states : Using a QPalette isn't guaranteed to work for all styles, because style authors are restricted by

QLabel auto multiple lines

痞子三分冷 提交于 2019-11-27 17:05:56
问题 For example, we have a QLabel with MaximumWidth set to 400. When we try to display some text with pixel width more than 400, it's shown cut off. Is there any way to make QLabel display this string in multiple lines without using QFontMetrics or the like? 回答1: If I understood your question correctly, you should use the setWordWrap function for your label, with true as its parameter. QLabel lbl("long long string"); lbl.setWordWrap(true); 回答2: In order to show multiple lines in QLabel, right

make QLabel clickable using PyQt5

可紊 提交于 2019-11-27 09:50:55
I have a Qlabel filled with QPixmap and I want to start a process/function once this label clicked. I had extended QLabel class as follows: from PyQt5.QtCore import * from PyQt5.QtWidgets import * from PyQt5.QtGui import * class QLabel_alterada(QLabel): clicked=pyqtSignal() def __init(self, parent): QLabel.__init__(self, QMouseEvent) def mousePressEvent(self, ev): self.clicked.emit() Then, in my pyuic5-based .py file (I used QtDesigner to do the layout) after importing the module where I save the extended QLabel class,inside the automatically generated setupui, function I changed my Label from

How to make the text fill all the QLabel's space?

谁说我不能喝 提交于 2019-11-27 07:37:46
问题 I am working on a PyQt5 project, but would be happy to read C++/Qt answer as well, because C++ solutions may work on Python too. I have a MainWindow with a horizontal layout, and a QLabel in it. My QLabel's size Policy is "Expanding", therefore all my window is filled by the QLabel. However, the text displayed by my QLabel does not change its size. I would like the text to grow when the window grows, and be as big as possible, in the limit of the QLabel size. I have heard of QWidget: