paintevent

PyQt5: Draw a line by clicking QPushButton

风流意气都作罢 提交于 2021-02-08 09:37:05
问题 I am trying to make it such that when I click a QPushButton a line is drawn. However the code I have right now makes the line at the beginning when the code is initiated and not after . The QPushButton doesn't seem to do any drawing. I also don't quite understand why when drawing you need an 'event' argument in the function. import sys from PyQt5 import QtCore, QtWidgets from PyQt5.QtWidgets import QMainWindow, QGridLayout,QPushButton, QApplication, QWidget from PyQt5.QtCore import QSize,

How to force calling of QWidget::paintEvent() when its hovered by other window?

帅比萌擦擦* 提交于 2020-01-30 13:15:10
问题 I have occured a problem: I'm writing a widget, which displays current date's day number. It's like a button, but it's not derived from QPushButton class. Just from QWidget . So I reimplemented enterEvent() , leaveEvent() , mousePressEvent() , mouseReleaseEvent() . I call update() inside these methods and widget has realistic button behavior ( paintEvent() is reimplemented too). But when I change system date and hover that widget with other window, my widget doesn't calls paintEvent() and

PySide2 paint on widget created by designer

纵饮孤独 提交于 2019-12-31 05:12:14
问题 This issue is with VS Code on Win10 and Python 3.6.6. I'm new both to Python and PySide2. I've read a lot of topics on this here at StackOverflow and possibly this is a duplicate of another topic, but I'm not able to get my widget painted. I understand that the paintEvent() of the widget object have to be overridden somehow. Most of the examples out there does some painting on the main window but I'm not able to transfer this on widgets from an ui.file. I've created two classes in my .py-file

Drawing points on QPixmap on QWidget (pyqt5)

自古美人都是妖i 提交于 2019-12-30 11:08:28
问题 I have a QWidget with a QLayout on which there is a QLabel. I set a QPixmap on the label. Wherever the user clicks on the image, I want to draw a point. I defined mouseReleaseEvent (which works) and paintEvent (but no points are drawn). I've read all similar questions and none of the solutions worked for me. Any help? My relevant code: class ImageScroller(QtWidgets.QWidget): def __init__(self, img): QtWidgets.QWidget.__init__(self) main_layout = QtWidgets.QVBoxLayout() self._image_label =

Handling VScrollbar Paint event

孤街醉人 提交于 2019-12-25 03:53:24
问题 I've been trying to handle the Paint event for a control on a form. However the event never gets handled, and I'm not sure what I'm doing wrong. I've created a very simple WinForms project to demonstrate this (I've included the generated designer code to show that there's nothing else there): Form1.vb Public Class Form1 Private Sub Form1_Load( sender As Object, e As EventArgs) Handles MyBase.Load AddHandler VScrollBar1.Paint, AddressOf VScrollBar1_Paint End Sub Private Sub VScrollBar1_Paint

Windows Form Paint equivalent event in WPF

房东的猫 提交于 2019-12-21 21:52:56
问题 I have used the PAINT event to draw a wave on a Panel in Winows Form Application. But when using it WPF, I didn't find any such element equivalent to a Panel which has a Paint Event. Googled a lot too but no great use. Well, I need to draw a waveform in WPF so suggest appropriate solutions wrt PaintArgsEvent or a new solution altogether. Thank You! 回答1: You are looking for the DrawingVisual Class From first Link: The DrawingVisual is a lightweight drawing class that is used to render shapes,

Calling paintEvent() from a class in pyqt4 python

孤街醉人 提交于 2019-12-20 03:13:52
问题 I have written a class to display rectangles (the cell class). I would like to have functions inside the class to call in another class (i.e. calling cell.paintEvent(self,event) and cell.drawRectangles(self,qp) in a function defined in a Window class). Unfortunately, I do not know how to call these functions in another class (i.e. Window) as they both require arguments (i.e. event and pq ) and I do not know what to pass on to them. Here is the code for my cell class: class cell(object): def _

How can I make paintEvent triggered only when update is called?

霸气de小男生 提交于 2019-12-13 09:46:06
问题 It is known that QWidget::paintEvent is triggered automatically the moment widget becomes visible or any event from the basic window happens. What should I do if I only want the paintEvent to be issued in response to update() ? 回答1: It'd make no sense for a paintEvent not to be issued whenever the widget needs to be painted. Your reason to demand such an option means that you're trying to use the Qt API in a way it wasn't meant to be used. I can't quite imagine yet a particular design that

Improving performance on bitmap images decoding on translating into view

我怕爱的太早我们不能终老 提交于 2019-12-11 06:25:24
问题 I'm developing an application which involves a slides translating into view as the primary navigation mechanism. The first slide to come in involves several super-imposed PNGs at roughly 2000px squared with transparencies, and there's a notable framerate stutter as the images come into view. Using Chrome Dev Tools' Timeline feature I've established that while most of the individual Paint tasks take under 5 milliseconds each, the significant outliers are those Paint events whose subtasks

Moving Object with Paint Event

若如初见. 提交于 2019-12-10 23:38:40
问题 I have a test tomorrow, and we must use the paint event to redraw our objects, we may not use a timer. As the MSDN says: "The Paint event is raised when the control is redrawn." , but that,occurs for my known, only when the form is minimized, or got invisible and back visible. My code: public partial class Form1 : Form { public Graphics drawArea; public int xPos, yPos; public Form1() { InitializeComponent(); } private void Form1_Paint(object sender, PaintEventArgs e) { drawArea = e.Graphics;