qlabel

Painting in a QLabel with paintEvent

好久不见. 提交于 2019-12-11 07:20:01
问题 I want to paint a rectangle in a certain label, I made a GUI with QtDesigner that generates the whole GUI code in one class called "class Ui_MainWindow(QMainWindow):" and I am using three tabs in my window. I had a problem using the QMouseEvent on my labels, I found a solution using this code from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtCore import Qt import sys import cv2 from PyQt5.QtWidgets import QMainWindow, QWidget, QLabel from PyQt5.QtGui import QPixmap, QImage class Ui

QRubberBand move when I resize window

自作多情 提交于 2019-12-11 06:17:21
问题 I want to make a selection, so I create a QRect with QRubberband, everything work fine, when i press the button I cand click o image and make a selection, the problem is the selection is moving when I resize the window, how can I stop this behviour? import sys from PyQt5 import QtCore, QtGui, QtWidgets # from PyQt4 import QtCore, QtWidgets class ResizableRubberBand(QtWidgets.QWidget): def __init__(self, parent=None): super(ResizableRubberBand, self).__init__(parent) self.draggable = False

Set text direction for QLabel?

依然范特西╮ 提交于 2019-12-11 02:45:07
问题 Is there a way to set the text direction for a QLabel? I've got a situation in which I have QLabel objects whose text is only punctuation, and I want that to be displayed either in RTL or LTR format. (For instance, parentheses or quotation marks need to reverse depending on the text direction.) I've tried calling QLabel::setLayoutDirection, but to no effect. #include <QApplication> #include <QLabel> int main(int argc, char **argv) { QApplication app (argc, argv); QLabel label(" :  «"); label

QPainter or QLabel is less costly to draw QPixmap

半城伤御伤魂 提交于 2019-12-10 22:38:08
问题 I have to create an Icon pixmap, two methods I am familiarized to do that, One is setting the pixmap as o QLabel and display it, and other is drawing pixmap using QPainter , ie Method one Icon::Icon { QLabel iconLab = new QLabel; QLabel iconName = new QLabel; iconLab->setPixmap("mypixmap.png"); iconName->setText("myiconname"); QVBoxLayout *iconLayout = new QVBoxLayout; iconLayout->setMargin(0); iconLayout->addWidget(iconLab, 1, Qt::AlignCenter); iconLayout->addWidget(iconName, 1, Qt:

Remove space from QLabel in a QTreeWidget

冷暖自知 提交于 2019-12-10 21:28:03
问题 I've added QLabel widgets to my QTreeWidget to work around the word wrapping issue in QTreeWidget. (see how to word wrap a QTreeWidgetItem). The QLabel widgets appear to have spacing around the text which for some reason disappears when the text wraps. It also does not show up when the Label text is blank. I tried setting setContentsMargin(0,0,0,0) on the QLabel but that didn't work. I also tried setStyleSheet("border: 0px; margin: 0px; padding: 0px;") which also didn't help. Screenshot: You

PyQt5: Updating Label?

安稳与你 提交于 2019-12-10 18:31:13
问题 I'm currently having trouble updating labels continuously, I have tried my different ways but either nothing happens or the program stops working. I have attached below part of my code. Also I was hoping someone could explain exactly the purpose of def retranslateUi(self, MainWindow): class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("Tom") MainWindow.setWindowModality(QtCore.Qt.NonModal) MainWindow.resize(800, 600) MainWindow.setAutoFillBackground(False)

QLabel::setPixmap() and QScrollArea::setWidget()

送分小仙女□ 提交于 2019-12-10 11:28:55
问题 I've been tracking down a bug that boils down to this - if you show an image label inside a scroll area, the label will not be resized to the image's size if QLabel::setPixmap() is called after QScrollArea::setWidget() . This example illustrates the problem, just replace /path/to/some/image.png with some real image on your computer: QScrollArea *scrollArea = new QScrollArea; QLabel *label = new QLabel(scrollArea); scrollArea->setWidget(label); label->setPixmap(QPixmap("/path/to/some/image.png

Interactively editing an existing rectangle on a QPixmap?

十年热恋 提交于 2019-12-09 08:04:18
I'm trying to creat a Dicom GUI Toolkit where the user selects some dicom images and the image of first dicom image from the selected ones will be shown. Then the user clicks on the image and the image pops out with bigger image window. In this shown bigger image, the image will consist of a red colored rectangle that contains necessary regions of the Dicom image while the unnecessary region is outside the rectangle. The user should then have the option to change the rectangle by mouse. Until now, I have been able to show the big dicom image with the rectangle in it using QLabel which is by

Interactively editing an existing rectangle on a QPixmap?

[亡魂溺海] 提交于 2019-12-08 05:00:47
问题 I'm trying to creat a Dicom GUI Toolkit where the user selects some dicom images and the image of first dicom image from the selected ones will be shown. Then the user clicks on the image and the image pops out with bigger image window. In this shown bigger image, the image will consist of a red colored rectangle that contains necessary regions of the Dicom image while the unnecessary region is outside the rectangle. The user should then have the option to change the rectangle by mouse. Until

Scaling QLabel to accommodate the contained text and nothing more

那年仲夏 提交于 2019-12-06 07:43:38
问题 I’m subclassing QLabel and inserting it into a QVBoxLayout and I’m having a problem with the size. The following screenshot is how my application currently looks: The yellow widget on the top is my QLabel , and the layout is the default one. I’d like my label to scale down to fit the text without manually setting it with setMinimumHeight() , however that wouldn’t allow me to use strings longer than the width of the label. I’ve checked the documentation for QString (which is what I am passing