QPainter::drawLine has problem in Large image's width
Recently, I had a problem in my application (So I provided a mini example of the problem) that I faced when creating large-scale images, and when I looked at the output image, it was not fully drawn! I...
View ArticleGet visible area of QPainter
I have an owner-drawn QWidget inside a QScrollArea, so when painting, and I want to paint only the parts that are visible. To do so, I need to have the rectangle of the visible area of the QPainter.The...
View ArticleHow to draw a picture instead of the slider of a QSlider?
I have created a class that inherits from QSlider and I want to draw a picture on the slider (grabber) instead of showing the plain one.How to do it?
View ArticlepaintEvent is not called after an update() in mouseMoveEvent
I am using a QAbstractScrollArea and a custom QWidget derivative widget as "the" widget(having sizeHint() overriden).The application needs to constantly update the QWidget content during mouseMove...
View ArticlePyQt6, drawing shapes over loaded PDF file
My goal is to create a PDF viewer that allows to draw a rectangle in front of the text. Right now the viewer part is done as well as the drawing rectangles part. The problem is, they don't work...
View ArticleHow to draw a gradient color wheel correctly using paint event without jagged...
I use the rotate method to draw the circle, but this creates gradual irregularities (visible on the outside of the circle).Furthermore, I can only get this result if I iterate ten times the hue value...
View ArticleHow to set QPdfView's viewport background color
I'm trying to set a QPdfView's viewport background color, but unlike QAbstractScrollArea (from which QPdfView's derived), using stylesheet does not work.Here's how I tried to do that:#include...
View ArticlePyqt6 draw double and triple bonds around an atom
I'm trying to draw possible bonds around a selected atom.I am using cos and sin to find the positions of the possible new atoms in steps of 45° so I get 8 different positions , which works fine. When...
View ArticleHow to get Bezier points from a curve
I am drawing a Bezier curve in Qt using the inbuilt Qt functions:void OpacityCurveWidget::paintEvent(QPaintEvent* event) { QPainter painter(this); painter.fillRect(0, 0, width(), height(), Qt::white);...
View ArticleQPainter::begin: Paint device returned engine == 0, type: 2
I'm trying to print Qtablewidget but it just print a blank page and application output showQPrinter::metric: Invalid metric commandQPainter::begin: Paint device returned engine == 0, type:...
View ArticleWhy is there extra spacing for some characters which cause QPainter::drawText...
I'm trying to use QPainter::drawText() to render some Chinese characters. But in certain fonts, there is extra top spacing when drawing the text. Why is this happening to some characters only?Tested on...
View Articledraw with QPaint on loaded QPixmap does not work
I can draw a Line on my Qlabel by doing this: QPixmap *myPixmap; myPixmap = new QPixmap(); myPixmap->fill(Qt::red); QPainter painter(myPixmap); painter.setPen(Qt::blue); painter.drawLine(1, 1, 50,...
View ArticleQOpenGLWidget with Qpainter: OpenGL drawing only visible after first paintGL...
I would like to use a QOpenGLWidget in QT to create fast line plots. These plots are to be provided with some labels, for which I am currently using QPainter with drawText(). In various examples, the...
View ArticleHow to get precise mouse pointer location/coordinate in PyQt5 QPainter?
I am trying to draw rectangle in real time in pyqt5 Using QPainter class.The problem here is that visually the mouse pointer location and the start and end points of the rectangle being drawn are...
View ArticleHow to draw a rectangle and adjust its shape by drag and drop in PyQt5
I'm trying to draw a rectangle on GUI created by PyQt5 by drag and drop. I managed to do that, but the rectangle is drawn when the mouse left key is released.What I want to do is like this link: When...
View ArticleProviding a list to a function
I've never come across this problem until now and can't think how to proceed.I would like to know how to provide each element of a tuple to a function that wants individual parameters:myTuple =...
View ArticleHow to make Qt widgets fade in or fade out?
I am trying to fade in and fade out a QLabel or for that matter any QWidget subclass. I have tried with QGraphicsEffect, but unfortunately it works well only on Windows and not on Mac. The only other...
View ArticleDrawing line to QImage
I am trying to draw line to QImage and show it in Qlabel. However I have some issues that I cannot solve. QPixmap px; px.fromImage (imgRaw); // define in header file QImage imgRaw; QPainter p...
View ArticleWhy is the position of the circles incorrect? [duplicate]
I am trying to use PyQt6 to design a program that draws a red circle at the position where the user clicks. However, when I click on the image in the window, the circle is not drawn exactly where I...
View ArticleQt: QWidget::paintEngine: Should no longer be called
I'm trying to make an app where you can draw with your finger on a canvas.To achieve this, I'm subclassing QWidget as MFCanvas, registered the class in QML withqmlRegisterType<>(), implementing...
View ArticlePySide How to apply smoothing (antialiasing)?
There is a drawn arrow indicator. Everything works well, but deep irregularities (burrs) remain on the red sectors. How to remove it?from PySide6.QtGui import QPainter, QColor, QPolygon, QPaintEvent,...
View ArticleHow to keep QPixamp quality in QPainter::drawPixmap when QPainter::scale(x,y)...
I am using QWidget and its paintEvent.Im using QPainter::scale(zoom,zoom) to scale background images on the widget.Then I want to paint some foreground icons and keep their size the same all the time...
View Articleqt drawing outlined text with QPainterPath
i have to draw outlined striked out text on QImage like that:I do it as follows:QPainter painter(this);QPainterPath path;QFont...
View ArticlePIL Image to PixMap Error on QImage Conversion
The following code block:class MDraw(QtWidgets.QGraphicsView): def __init__(self, parent): super(MDraw, self).__init__(parent) self.data = None self.width = 0 self.height = 0 def resizeEvent(self,...
View Article"scale from center of rectangle" not work with world transform matrix
I have a qtquick project with a main.qml and an EaDrawArea which inherits from QQuickPaintedItem and is accessible from the main.qml. there is a Slider in the qml which is binding to m_scale (3 to 100)...
View ArticleUsing QPainter’s drawPixmap/drawImage to draw images, the images look blurry
I used QPainter’s drawPixmap() to draw an image, and the result is shown as B in the following picture.Then, I opened the same image in the image viewer program provided by Windows, zooming it even...
View ArticleQT the pixel difference that occurs when drawing a font table on the screen...
I am drawing a font table in Qt. I noticed that when I draw the table directly on the screen and when I draw it first on an qimage and then draw this image on the screen, the letters are shifted a few...
View ArticlePaint device returned engine == 0, type: 1
I have seen many answers for the same Question, I have already gone through them but none them solved my problem, I am getting the error QWidget::paintEngine: Should no longer be called...
View ArticleHow to fix a rendering issue with QItemDelegateClass::drawCheck?
I have a custom delegate which is added to the first column of a QTableView. The code is below. I am experiencing a strange rendering issue for the checkboxes on the table view.When all checkboxes...
View ArticleHTML to PDF using Qt not show all characters
I am having an issue with exporting HTML to PDF using Qt version 6.8. Some characters simply do not appear in the final file, and interestingly, if I try to select the text and press Ctrl+C and then...
View Article