qlabel

Hide or crop overlapping text in QLabel?

十年热恋 提交于 2019-12-02 22:10:17
问题 I'm currently building a UI where I do have 3 labels that are arranged in a horizontal layout: | textLabel | valueLabel | unitLabel | The valueLabel and unitLabel are aligned right. unitLabel has a fixed width, valueLabel 's width is variable and depends on the text length inside it. textLabel is aligned left and fills the remaining horizontal space right up to the valueLabel . So, in other words, the textLabel 's width is not fixed but depends on the width of valueLabel . My problem: when

updating QLabel in non-GUI thread continuously

牧云@^-^@ 提交于 2019-12-02 19:04:31
问题 I access the Qt GUI's QLabel's QPixmap in another thread since I will finally use this to display mjpeg stream in QLabel, and I decided to use QLabel since its the easiest way It should look like 'Live' and not block the UI thus using another (non-gui) thread. nothing shows up in the QLabel. only the exception QPixmap: It is not safe to use pixmaps outside the GUI thread any better or correct way to do this ? here is my PyQt code of another thread: self.theQlabel.setPixmap(QtGui.QPixmap

How to update a window in QT?

扶醉桌前 提交于 2019-12-02 18:07:54
问题 Im working on a simple project in QtCreator where you input text into a line_edit which then gets printed after clicking a button. It works but I need to resize the window in order to see the updated/changed display. So starting off with the main.cpp, I have left it as default after some tests: #include "mainwindow.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); } That has the issue I was talking about above. I

How to QPainter inside QLabel

陌路散爱 提交于 2019-12-02 14:41:19
问题 I can not understand how to make the QPainter() draw inside a QLabel, here is the code I told would have worked: import sys from PyQt5.QtWidgets import * from PyQt5.QtGui import QPainter, QColor, QBrush class Labella(QLabel): def __init__(self, parent): super().__init__() lb = QLabel('text', parent) lb.setStyleSheet('QFrame {background-color:grey;}') lb.resize(200, 200) qp = QPainter(lb) qp.begin(lb); qp.setBrush(QColor(200, 0, 0)) qp.drawRect(0,0,20,20); qp.end(); def paintEvent(self, e): qp

pyqt qlabel displays only first char of string

匆匆过客 提交于 2019-12-02 12:17:55
问题 I want to display some string in QLabel on button click but my code only shows first char of the string. I am using following code for this class UITesterWindow(QWidget): def __init__(self, parent=None): super(UITesterWindow, self).__init__(parent) self.test2 = QPushButton("Test1", self) self.test2.setGeometry(10, 360, 200, 30) self.test2.setStyleSheet("font: bold 12pt Courier") self.emailIDIN = QtGui.QLabel(self) self.emailIDIN.setStyleSheet("font: bold 18pt Courier") self.emailIDIN.move(420

updating QLabel in non-GUI thread continuously

南楼画角 提交于 2019-12-02 11:35:57
I access the Qt GUI's QLabel's QPixmap in another thread since I will finally use this to display mjpeg stream in QLabel, and I decided to use QLabel since its the easiest way It should look like 'Live' and not block the UI thus using another (non-gui) thread. nothing shows up in the QLabel. only the exception QPixmap: It is not safe to use pixmaps outside the GUI thread any better or correct way to do this ? here is my PyQt code of another thread: self.theQlabel.setPixmap(QtGui.QPixmap.fromImage(myQimg) Instead of directly setting the pixmap, make the external thread emit an updatePixmap

How to update a window in QT?

二次信任 提交于 2019-12-02 10:52:56
Im working on a simple project in QtCreator where you input text into a line_edit which then gets printed after clicking a button. It works but I need to resize the window in order to see the updated/changed display. So starting off with the main.cpp, I have left it as default after some tests: #include "mainwindow.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); } That has the issue I was talking about above. I decided to add w.update(); and see if that fixed the issue, it did not. I thought maybe it was because

Make Qlabel clickable or double clickable in Qt

主宰稳场 提交于 2019-12-02 06:31:54
I am beginner in Qt, now I want to make my label clickable, I have searched so much online, but no one gives my a real example of how they made it. So can someone teach me step by step? Now my basic thinking is creating a new .c file and new .h file respectively and then include them into my mainwindow.c and then connect it with the existing label in ui form. These are what I was trying to do, but can not make it. Hope someone can teach and better put the step picture in the command, thanks. Here is the clicklabel.h code: #ifndef CLICKEDLABEL_H #define CLICKEDLABEL_H #include <QWidget>

pyqt qlabel displays only first char of string

╄→尐↘猪︶ㄣ 提交于 2019-12-02 05:53:46
I want to display some string in QLabel on button click but my code only shows first char of the string. I am using following code for this class UITesterWindow(QWidget): def __init__(self, parent=None): super(UITesterWindow, self).__init__(parent) self.test2 = QPushButton("Test1", self) self.test2.setGeometry(10, 360, 200, 30) self.test2.setStyleSheet("font: bold 12pt Courier") self.emailIDIN = QtGui.QLabel(self) self.emailIDIN.setStyleSheet("font: bold 18pt Courier") self.emailIDIN.move(420, 170) class SecondWindow(QMainWindow): def __init__(self, parent=None): super(SecondWindow, self)._

Displaying gif in PyQt GUI using QLabel

风流意气都作罢 提交于 2019-12-02 03:30:46
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.move(20,50) self.show() def gif_display(self): l = QMovieLabel('loading.gif') l.show() class