qlabel

Open and save image file using menubar in PyQt5

浪子不回头ぞ 提交于 2020-01-05 05:27:15
问题 I've written the following code to open image file using a menubar in PyQt5. It is able to select the file but not able to display it in the window. I've successfully opened text file but not able to do the same for images. Can you please rectify my error? import sys from PyQt5.QtWidgets import QMainWindow, QApplication, QWidget, QLabel, QFileDialog, QAction from PyQt5.QtGui import QIcon, QPixmap class MainWindow(QMainWindow): def __init__(self, parent = None): super(MainWindow, self).__init_

Open and save image file using menubar in PyQt5

懵懂的女人 提交于 2020-01-05 05:27:15
问题 I've written the following code to open image file using a menubar in PyQt5. It is able to select the file but not able to display it in the window. I've successfully opened text file but not able to do the same for images. Can you please rectify my error? import sys from PyQt5.QtWidgets import QMainWindow, QApplication, QWidget, QLabel, QFileDialog, QAction from PyQt5.QtGui import QIcon, QPixmap class MainWindow(QMainWindow): def __init__(self, parent = None): super(MainWindow, self).__init_

How to load an image with QLabel in PySide2

大城市里の小女人 提交于 2020-01-03 00:38:20
问题 I'm a beginner in coding and python. I read that tkinter is a bit to "basic" if you want to develop an application which is a a bit more complicated and PyQt is problematic for licencing. This is why I chose PySide2 in order to develop this kind of project, but found so far the documentation relatively scarce. Is this the right choice? My present coding problem is the following: I'm Trying to load an image with PySide2 without success. Here is the code of my 2 attempts: Attempt N°1: import

Underline QLabel's text “on hover”

无人久伴 提交于 2020-01-02 07:58:30
问题 I want to turn the text green and underline it when the mouse cursor goes over a QLabel , however, it just turns green, it does not get underlined. QLabel:hover { color: green; text-decoration: underline;} What am I doing wrong? EDIT: Fixed, I used: void QClickableLabel::enterEvent (QEvent *event) { Q_UNUSED (event); setStyleSheet ("QLabel { color: green; text-decoration: underline; }"); } void QClickableLabel::leaveEvent (QEvent *event) { Q_UNUSED (event); setStyleSheet ("QLabel { color:

How to add both an image and text to a QLabel

扶醉桌前 提交于 2020-01-02 07:23:08
问题 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

How to add both an image and text to a QLabel

倖福魔咒の 提交于 2020-01-02 07:23:03
问题 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

QLabel click event using Qt?

試著忘記壹切 提交于 2019-12-30 08:52:09
问题 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 ?! 回答1: 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 click event using Qt?

让人想犯罪 __ 提交于 2019-12-30 08:52:06
问题 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 ?! 回答1: 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

QRubberBand and MPlayer in QLabel

偶尔善良 提交于 2019-12-25 07:46:46
问题 I have already tried many solution that are provided on stackoverflow to make it transparent. I want to make QRubberBand transparent and i am also facing problem regarding that green color which is due to mplayer. #include "physician.h" #include "ui_physician.h" Physician::Physician(QWidget *parent) : QMainWindow(parent), ui(new Ui::Physician) { ui->setupUi(this); ui->sendROIButton->setStyleSheet( "background-color: #d9d9d9;" "border-radius: 10px;" "color: Black; " "font-size: 15px;" ); }

QLabel OpenCV Image Coordinates in Qt

安稳与你 提交于 2019-12-24 13:23:13
问题 I would like to do manipulations on the image with OpenCV based on mouseClicks. I am using QLabel to display cv::Mat images. Now my problem is with getting the mouse clicks positions with respect to the image. So, I would like (0,0) at topleft corner of the image. Following is my mousePressEvent, but these are not correct co-ordinates. void MainWindow::mousePressEvent( QMouseEvent* ev ) { //This seems to work thanks to Pavel QPoint P = ui->label->mapFrom(this, ev->pos()) //if( ui->label-