qlabel

Draw on top of image

怎甘沉沦 提交于 2019-12-06 02:59:59
问题 I'm new to PyQt5 and I couldn't find any answers that worked for me about how to draw with QPainter on top of a loaded image (QPixmap("myPic.png")). I tried doing it within a paintEvent method but it didn't work. If I want to draw a line on top of the loaded image in the snippet below, how would I go about doing it? import sys from PyQt5.QtWidgets import * from PyQt5.QtGui import * class Example(QWidget): def __init__(self): super().__init__() self.setGeometry(30, 30, 500, 300) self.initUI()

How to add both an image and text to a QLabel

好久不见. 提交于 2019-12-06 01:38:55
I have a QHBoxLayout with a QLabel in it, and I'm trying to get both an icon and window title text in the QLabel. Is that possible? Or even to add the icon directly to the QHBoxLayout, so that is is laying just before the window title text? Here is my code: class MyBar(QWidget): def __init__(self, parent): super(MyBar, self).__init__() self.parent = parent self.layout = QHBoxLayout() self.layout.setContentsMargins(0,0,0,0) self.title = QLabel("Main Window") def changetitle(self, msg): self.title.setText(msg) Edit: Here is the code where I used two labels side by side: self.label3 = QLabel(self

Qt QLabel click event

放肆的年华 提交于 2019-12-05 11:33:58
I'm new in Qt and have a question. I have QLabel and QLineEdit objects, and when QLabel text is clicked on, I want to set this text in QLineEdit . Also I have read that QLabel has not clicked signal. Can you explain how can I do this and write code for me ?! Either style another type of QWidget such as a specific QPushButton to look like a QLabel and use its clicked() signal or inherit QLabel yourself and emit your own clicked() signal. See this example: https://wiki.qt.io/Clickable_QLabel If you choose the latter option you can pass the text in the signal. Then connect the necessary signals

QLabel showing an image inside a QScrollArea

只谈情不闲聊 提交于 2019-12-05 07:18:33
I've successfully implemented a Image Viewer (for DICOM) in Qt. I can see the image and I can zoom in and out correctly. Now, I want to see scroll bars if the image is too big to show when I zoom in. I've used the UI. I placed a QScrollArea . Inside, the QLabel . The verticalScrollBarPolicy is ScrollBarAsNeeded . The horizontalScrollBarPolicy is ScrollBarAsNeeded . The problem is: it doesn't work. I zoom in, but no scrollbar appears. Second try: using a layout inside the QScrollArea. So now there's a QWidget between the QScrollArea and the QLabel: a horizontal layout. Opened the same image,

How to display Arabic notations in left-to-right direction in QLineEdit/QLabel etc.?

痴心易碎 提交于 2019-12-05 04:32:22
问题 In Qt's implementation arabic notation is shown in right-to-left direction, thus any strings that contain arabic notations will be right-aligned. But what my application wants to do is showing all texts in left-to-right direction, whether it contains arabic notations or not. And all texts are left-aligned. An example is shown below: This is what I want to implement This is how QLineEdit displays texts containing arabic notations in its default way This is how QLabel does it EDIT: Paste the

Trouble displaying sequence of images with setPixmap in Qlabel

牧云@^-^@ 提交于 2019-12-04 18:31:18
I'm trying to display a sequence of images through a Qlabel using setPixmap. I have a QStringList containing the image file names and a for loop which iterates through the images with a 5 second wait after each image. However, only the last image file is ever being displayed. Currently the screen remains blank during the wait of the first iterations until the last image is finally shown. I've read that using a for loop wont work and that I should be using signals and slots instead. I'm new to this concept though and I would really appreciate an example to point me in the right direction. Here

Scaling QLabel to accommodate the contained text and nothing more

耗尽温柔 提交于 2019-12-04 13:45:05
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 to the label’s constructor) and I can’t find a way to extract the size of the text. Is there any way I

Draw on top of image

本秂侑毒 提交于 2019-12-04 06:26:37
I'm new to PyQt5 and I couldn't find any answers that worked for me about how to draw with QPainter on top of a loaded image (QPixmap("myPic.png")). I tried doing it within a paintEvent method but it didn't work. If I want to draw a line on top of the loaded image in the snippet below, how would I go about doing it? import sys from PyQt5.QtWidgets import * from PyQt5.QtGui import * class Example(QWidget): def __init__(self): super().__init__() self.setGeometry(30, 30, 500, 300) self.initUI() def initUI(self): self.pixmap = QPixmap("myPic.png") lbl = QLabel(self) lbl.setPixmap(self.pixmap) self

How to display Arabic notations in left-to-right direction in QLineEdit/QLabel etc.?

不羁岁月 提交于 2019-12-03 21:40:52
In Qt's implementation arabic notation is shown in right-to-left direction, thus any strings that contain arabic notations will be right-aligned. But what my application wants to do is showing all texts in left-to-right direction, whether it contains arabic notations or not. And all texts are left-aligned. An example is shown below: This is what I want to implement This is how QLineEdit displays texts containing arabic notations in its default way This is how QLabel does it EDIT: Paste the test string here. ە抠门哥ە( EDIT: Providing an alternate solution. Finally I can achieve my goal roughly by

clickable event on QLabel in python using pyqt4?

邮差的信 提交于 2019-12-03 06:04:27
I am working in python GUI using pyqt4 library and new with signal and slots. I don't know how to put event on label name QPLabel . Here is my code : class Ui_Form(object): def setupUi(self, Form): Form.setObjectName(_fromUtf8("Form")) Form.resize(759, 598) font = QtGui.QFont() font.setPointSize(12) ... ... ... self.QPLabel = QtGui.QLabel(Form) self.QPLabel.setGeometry(QtCore.QRect(620, 420, 141, 20)) QtCore.QObject.connect(self.QPLabel, QtCore.SIGNAL(_fromUtf8("clicked()")), self.doSomething) def doSomething(self): print 'Label click' Anybody what should I do for event on label for doing some