Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    1. Home
    2. Tags
    3. qpainter
    Log in to post

    • UNSOLVED Web enabling a desktop app.
      QtWebEngine • qgraphicsscene qpainter web app • • TenG  

      4
      0
      Votes
      4
      Posts
      41
      Views

      @TenG Be aware that not all of Qt modules are supported in WASM. Before anything, check the list at https://doc.qt.io/qt-5/wasm.html#supported-qt-modules against what is in your app. For example, it doesn't do databases, you can't access the local file system, and so on. Also I noticed this time that it requires a Qt static build, but maybe you have to have that for iOS anyway, I don't know. If it works for you it's a really simple solution compared to rewriting anything. Just check out the gotchas.
    • UNSOLVED MacOS : QOpenGLWindow + QOpenGLWidget in MainWindow + QPainter causes repaint bug
      General and Desktop • qpainter macos qopenglwindow • • Karpi  

      9
      0
      Votes
      9
      Posts
      74
      Views

      Thanks for the code ! You can use the Q_OS_XXX macros to ifdef your code.
    • UNSOLVED Does QPainter tries to paint anything outside the size of paint device?
      General and Desktop • qpainter qimage • • CJha  

      2
      0
      Votes
      2
      Posts
      54
      Views

      so write a test program, meter the performance of canvas writes vs out-of-bounds writes, and report back.
    • UNSOLVED SVG generator - precision / size
      General and Desktop • qpainter svg precision • • vania2020  

      1
      0
      Votes
      1
      Posts
      39
      Views

      No one has replied

    • UNSOLVED QPainter: QImage vs QPixmap
      General and Desktop • qpainter qimage qpixmap • • CJha  

      7
      0
      Votes
      7
      Posts
      252
      Views

      Just let Qt do its work. If by drawing directly on QWidget you mean subclassing it and rewriting its Paint() method - don't do it unless you absolutely have to. Or, when you need to provide a delegate for a view. So far I've not had the necessity to dive that deep. And since you can display (and scale) images and videos using QLabel, push buttons can be readily supplied with an icon... I just had not need. Then again, your needs might differ.
    • SOLVED Getting double precision floating point accuracy out of QSvgGenerator?
      General and Desktop • qpainter svg • • RobbieP  

      2
      0
      Votes
      2
      Posts
      39
      Views

      Solved it by changing my drawline to: painter.drawLine(QPointF(pX1, pY1), QPointF(pX2, pY2));
    • SOLVED Creating QImage from a QML component?
      General and Desktop • qpainter libopenshot • • Wiru  

      3
      0
      Votes
      3
      Posts
      52
      Views

      Thank you, I think this will do just perfect!
    • UNSOLVED How do I scale an image with QPainter?
      General and Desktop • qpainter • • lansing  

      3
      0
      Votes
      3
      Posts
      100
      Views

      @Bonnie Thank you, setting it before drawPixmap works. I don't need any smoothing so nearest neighbor resize is fine for me.
    • UNSOLVED Painter not painting over 32,765 px in width of QGraphicsItem/QGraphicsObject
      General and Desktop • qpainter qgraphicsitem qgraphicsobject • • lansing  

      3
      0
      Votes
      3
      Posts
      47
      Views

      @mrjj Thanks, so I hit the limit. I'll try not to go over that.
    • UNSOLVED Automatic Clipping in QPaintEvent cuts away parts of the drawing result
      General and Desktop • qwidget qpainter qpaintevent paint event clipping • • Allgaeuer  

      1
      0
      Votes
      1
      Posts
      51
      Views

      No one has replied

    • UNSOLVED QPainter drawRects without draging a line behind
      Game Development • qt5 qpainter qvector game qrectf • • Mquaza  

      2
      0
      Votes
      2
      Posts
      117
      Views

      @Mquaza said in QPainter drawRects without draging a line behind: How do you make it so, that 2 rectangles are moving across the scene? I would say change their coordinates?
    • SOLVED How to draw something with QPainter when the button is pushed
      General and Desktop • qpainter event handling • • TrueNova  

      3
      0
      Votes
      3
      Posts
      81
      Views

      @SamurayH The solution is perfect to me. Thank you very much!
    • SOLVED QPainter ignore the text when the clipping is applied while printing to a PDF document
      General and Desktop • qpainter text pdf print clipping • • jeanmilost  

      3
      0
      Votes
      3
      Posts
      81
      Views

      @mrjj Thank you for your answer. So I tested to remove the text rectangle passed to the drawContents() function, and indeed the global clipping was applied instead.
    • SOLVED How to can i stop from painting the background widget in paintevent?
      General and Desktop • c++ qpainter qwt graph qpaint • • Yash001  

      11
      0
      Votes
      11
      Posts
      671
      Views

      @mrjj Thank you sir for helping me and direction. I am able to solve this issue by setting the clipping area properly on graph. Use QWidget::update() instead of QWidget::repaint().
    • UNSOLVED Replace QTreeView::branch using pixmap ?
      General and Desktop • qtreeview qpainter qpixmap • • Dariusz  

      12
      0
      Votes
      12
      Posts
      132
      Views

      Then maybe QTreeView::drawBranches is what you are looking for.
    • UNSOLVED How to paint to pixmap ?
      Qt for Python • qwidget qpainter • • Dariusz  

      12
      0
      Votes
      12
      Posts
      1761
      Views

      @SGaist Ok that sounds a bit bad like - "delete while in use" situation. So it seems plausible it could crash from that in some cases.
    • SOLVED qpainter performance
      General and Desktop • opengl qpainter performance • • dalishi  

      7
      0
      Votes
      7
      Posts
      391
      Views

      @kent-dorfman Thanks and will try out those methods also.
    • UNSOLVED QPainter.begin
      General and Desktop • qpainter • • GrahamLa  

      2
      0
      Votes
      2
      Posts
      450
      Views

      Some of the reasons are right there in the documentation: QPainter::begin(). Generally speaking begin() returns false when the underlying resources are unavailable - another painter is active on that device, trying to paint to a null device or image, underlying paint engine is uninitialized or non existing etc. For end() it's similar - either the painter in not active on any device or the underlying paint engine failed to end the operation for whatever reason. There is no API for getting the reason of failure of any of those as it would be hard to make one considering there are different paint engines and you can even make one yourself. It would have to be something really generic like a string, and having users parse that and basically expect every possible reason on every supported platform would not be a good API.
    • UNSOLVED QTableWidget draw/Paint over widget in a cell ?
      General and Desktop • qwidget qtablewidget qpainter • • Dariusz  

      7
      0
      Votes
      7
      Posts
      1225
      Views

      You won't get a paint event at all during drag'n'drop I would guess since the cursor is not directly painted by Qt when I'm correct.
    • UNSOLVED QPainter zero point bug
      General and Desktop • qpainter qt 5.9.0 • • goldstar2154  

      2
      0
      Votes
      2
      Posts
      288
      Views

      kind of shooting in the dark here, but remember that the painter coordinate system can be scaled, rotated, and new origin set. Try explicitly defining the coordinate system...Also, if your coordinates are floating point then you have to deal with floating point roundoff error.
    • SOLVED QWidget::paintEngine: Should no longer be called
      General and Desktop • qgraphicsview qpainter painteevent • • Staslend  

      10
      0
      Votes
      10
      Posts
      2441
      Views

      @Staslend if your issue is solved, please don't forget to mark your post as such! Thanks.
    • UNSOLVED How to properly trigger paintGL function ?
      General and Desktop • qpainter qopenglwidget qtime qpaint fps • • Dariusz  

      2
      0
      Votes
      2
      Posts
      338
      Views

      Ok solved It appears that a GLOBAL surface setInterval overrides the setIntervals I did on my glWidget. Kinda weird that the global one overrides local one if local one was specified, is this a bug ? format.setSwapInterval(0); QSurfaceFormat::setDefaultFormat(format); overrides on widget > QSurfaceFormat format; format.setSwapInterval(0); setFormat(format);
    • UNSOLVED How to draw shapes bellow a specific element using its position with QPainter and draw functions ?
      General and Desktop • qpainter paintevent drawing • • DSpider  

      2
      0
      Votes
      2
      Posts
      282
      Views

      Hi Well to get below the QWTPlot plot would be QWTPlotptr->y() + QWTPlotptr->height() However, a more solid approach could be to use a QLabel as a canvas using a pixmap. That way, its very easy to position even if using layouts to make GUI auto adjust to different screen sizes. void PaintShapes() { // take size of label int h = ui->label->height(); int w = ui->label->width(); // make a pixmap of the wanted size QPixmap pix(w, h); // assign painter to it so we can paint on it QPainter paint(&pix); // fill it pix.fill( Qt::white ); // paint on canvas paint.setPen(QColor(0, 0, 0, 255)); paint.drawRect(0, 0, w, h); ..other paint operations-.. // set the pixmap to the label so its shown. ui->label->setPixmap(pix); }
    • SOLVED QGraphicsView/Scene paints over other widgets
      General and Desktop • qgraphicsview qgraphicsscene qpainter qpainterpath • • Niagarer  

      11
      0
      Votes
      11
      Posts
      1833
      Views

      @Niagarer Good found. :)
    • UNSOLVED QPainter::setClipping(false) is not working(Qt 4.8)
      General and Desktop • qwidget qpainter paintevent clipping • • arju.ach  

      14
      0
      Votes
      14
      Posts
      1052
      Views

      You can make a "container widget" that will handle the showing of the label properly.
    • UNSOLVED Рисование линии Qt
      Russian • qpainter • • Zhukov  

      4
      0
      Votes
      4
      Posts
      2769
      Views

      @Zhukov said in Рисование линии Qt: Как передать точки x,y,x1,y1 в paintEvent()? Как показали выше: сохранить координаты в полях класса, вызвать update() (repaint лучше не юзать без особых причин) и использовать эти поля в paintEvent() Как вариант, можно использовать QPainterPath или даже QPicture, это хорошо подойдет если планируется рисовать много линий и добавлять/убирать их в процессе работы приложения. Еще можно нарисовать линии в QImage и затем рисовать получившуюся картинку в paintEvent(), хорошо подойдет для реализации растрового редактора типа MS Paint, но будет привязка к конкретным размерам картинки в пикселях. Как использовать paintEvent() в любой момент? Никак, paintEvent вызывается в моменты перерисовки окна графической системой. Если вызвать repaint(), то эта перерисвока произойдет практически сразу же, но лучше не делать код, зависящий от предположения мгновенной перерисовки, и использовать update
    • UNSOLVED Can't draw rectangle on a Custom Video Widget with Paint Event
      General and Desktop • qpainter qvideowidget qrect • • onurcevik  

      20
      0
      Votes
      20
      Posts
      1905
      Views

      @onurcevik Did you ever figure the solution for this? Working on it now
    • UNSOLVED Canvas/QPainter bug
      QML and Qt Quick • qpainter zoom canvas • • f.serreau  

      2
      0
      Votes
      2
      Posts
      892
      Views

      Hi @f.serreau I have tested your example, and it works correctly with no errors. I tested it on Windows 10 (Fall Update), MS VS2017 and Qt 5.11.0.
    • UNSOLVED Issue with QPainter, opacity and multiline text
      General and Desktop • qpainter opacity drawtext multiline • • fsilva  

      6
      0
      Votes
      6
      Posts
      1057
      Views

      Sorry, I don't have the XPS printer available. Can you check whether you have the same result with the QPdfWriter class ?
    • UNSOLVED Drawing directly with QPainter and drawing QPixmap give different results
      QML and Qt Quick • qpainter qpixmap qquickpaintedit • • mdma2  

      2
      0
      Votes
      2
      Posts
      1105
      Views

      @mdma2 Can you post the full code of this short example, so that it can be tried out immediately using simple copy/paste...
    • UNSOLVED How can I use QPainter to paint on QGraphicsView?
      General and Desktop • qgraphicsview qgraphicsscene qpainter draw objects • • elmLiu  

      9
      0
      Votes
      9
      Posts
      8415
      Views

      In your MyView::paintEvent write QPainter painter(viewport()); instead of QPainter painter(this);.
    • UNSOLVED Implementing QAbstractTextDocumentLayout::draw
      General and Desktop • qpainter widgets draw qabstracttextdo documentlayout • • Arthur Araruna  

      2
      0
      Votes
      2
      Posts
      258
      Views

      Hi Arthur, Sorry you did not get any feedback for your issue after so long, shows there must be a minimal use or understanding of this class. Did you get help or find solution you can share. I'm also trying to find help using this class and lack of doc is still there I'm afraid. One possibility is to look at KoTextDocumentLayout.h and cpp files, these might help with some information. https://github.com/JeremiasE/KFormula/blob/gsoc/libs/kotext/KoTextDocumentLayout.h
    • UNSOLVED QPainter drawRect does not work with GL_CULL_FACE
      General and Desktop • opengl qpainter qopenglwidget • • dalishi  

      2
      0
      Votes
      2
      Posts
      496
      Views

      @dalishi You should not mix painter and gl calls like that. You should put gl calls between calls to beginNativePainting() and endNativePainting(), which are painter functions. It might also help to save the painter state before and restore it after depending on how it messes up your gl stuff. the docs here tell you what the painter does to the states.
    • UNSOLVED Qpainter scale pixmap to parent with aspect ratio
      General and Desktop • qpainter scale to fit aspect ratio pixm • • pauledd  

      15
      0
      Votes
      15
      Posts
      6892
      Views

      Ok, I will try that... Maybe I should have been more clearly what I intend to get... I had it all working already, just without the scaling issue I get camera images and I let opencv compute min/max values and a centerpoint. Somethimes the camera is rotated in a undesired position so the user should be able to rotate the view, including the measurepoints, and more complex including the point values so that the stay at the points but do not rotate staying readable... I keep trying with qpainter draw
    • UNSOLVED How to achieve this effect with QPixmap?
      General and Desktop • qpainter qimage qpixmap pixmap paint • • John27  

      7
      0
      Votes
      7
      Posts
      1124
      Views

      @VRonin Yes, they are, but the pixmap is just grabbed QGraphicsView's content using grab() method.
    • UNSOLVED QPainter drawing lines - configuring line softness (horizontal opacity gradient)
      General and Desktop • qpainter qline • • Vagabond  

      3
      0
      Votes
      3
      Posts
      771
      Views

      @mrjj Thanks! I'll look into that. I got another reply from stackoverflow which I will also give a shot. I'll keep everyone in both forums posted as soon as I have some results.
    • SOLVED QPainter::drawText display corrupted text on a QOpenGLWidget
      General and Desktop • qpainter qopenglwidget qt5.6.3 • • Alain38 0  

      3
      0
      Votes
      3
      Posts
      901
      Views

      Hi, Glad you found out and thanks for sharing ! What version of Qt are you using ? On which platform ? Did you check the bug report system to see if it's something known ?
    • UNSOLVED Using hardware acceleration(GPU) for QWidget::paintEvent()
      General and Desktop • qwidget qpainter qpaintevent gpu gpu acceletator • • SilverSurfer  

      6
      0
      Votes
      6
      Posts
      2726
      Views

      It uses the raster engine. See here for historical informations.
    • SOLVED Deleting rectangle drawn by QPainter
      General and Desktop • qpainter • • gabor53  

      11
      0
      Votes
      11
      Posts
      5803
      Views

      The following solution worked: #include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; } void MainWindow::paintEvent(QPaintEvent *event) { QPainter painter(this); QFont font = painter.font (); font.setFamily ("Arial"); font.setPixelSize (25); painter.setFont (font); painter.setPen (Qt::white); QRect rect(100, 120, 200, 50); painter.setBrush (Qt::blue); painter.drawRect (rect); painter.drawText (rect, Qt::AlignCenter, tr("Record deleted.")); painter.end(); QTimer::singleShot(3000,this,&MainWindow::hideRect); update(); } Thank you for your help.
    • UNSOLVED Resizing a constant Video stream from OpenCV to PyQt5 with QPainter in a QWidget using a Raspberry Pi
      Language Bindings • qwidget python qpainter opencv pyqt • • Xenoshell  

      24
      0
      Votes
      24
      Posts
      12884
      Views

      Yeah i feel like i do sudo apt-get update && upgrade at least once a day. I just checked about SIP and i compiled it from source but i cant remember if i actually used the command make and make install. Does that mean i have to reinstall pyqt5 again? I guess i just open a new thread. Thanks for all the help @SGaist