Navigation

    Qt Forum

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

    • UNSOLVED Replace QTreeView::branch using pixmap ?
      General and Desktop • qtreeview qpainter qpixmap • • Dariusz  

      12
      0
      Votes
      12
      Posts
      57
      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
      89
      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
      183
      Views

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

      2
      0
      Votes
      2
      Posts
      206
      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
      623
      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
      232
      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
      1178
      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
      237
      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
      191
      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
      964
      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
      920
      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
      1709
      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
      1300
      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
      658
      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
      765
      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
      666
      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
      4668
      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  

      1
      0
      Votes
      1
      Posts
      192
      Views

      No one has replied

    • UNSOLVED QPainter drawRect does not work with GL_CULL_FACE
      General and Desktop • opengl qpainter qopenglwidget • • dalishi  

      2
      0
      Votes
      2
      Posts
      380
      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
      4633
      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 paint pixmap • • John27  

      7
      0
      Votes
      7
      Posts
      960
      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
      572
      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
      695
      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
      1798
      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
      4081
      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
      10469
      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
    • SOLVED Render image from hsv color
      General and Desktop • qwidget qpainter rendering python3 drawpixmap • • Adam V  

      8
      0
      Votes
      8
      Posts
      2391
      Views

      I have found a solution that kind of does the job, although takes three times as much memory. Every update I calculate the difference between the new and the old saturation matrix, this eliminates 60% of the nonzero values, which means it gets drawn that much faster. As a second layer of optimization I call repaint with a rectangle describing the most important zone, and call update every 60ms.
    • SOLVED How to add watermark of one QImage with Qt ?
      General and Desktop • qpainter qimage watermark • • mounipanditi  

      8
      0
      Votes
      8
      Posts
      2516
      Views

      @joeQ As per your suggesttion i'll make changes in the code on my own.Once again thanks for your help.
    • UNSOLVED Image composition with QWidget as a painting device.
      General and Desktop • qpainter compositionmode • • skrech  

      2
      0
      Votes
      2
      Posts
      618
      Views

      Not all paint devices (widgets, images, etc) support all composition modes. QImage does, but QWidget might not, which is what I suppose is happening here.
    • UNSOLVED paintEvent is not painting complete objects
      General and Desktop • qpainter qpaintevent • • NIXIN  

      11
      0
      Votes
      11
      Posts
      3707
      Views

      @VRonin Depends on what he wants to achieve. Is it a widget, than I agree with you. Is it some CAD-drawing (looks like a diagram symbol to me), then I would prefer drawing. For the latter the Graphics View Framework would be more practical though.
    • SOLVED Not able to draw lines inside QPaintEvent
      General and Desktop • qpainter qpaintevent • • NIXIN  

      3
      0
      Votes
      3
      Posts
      727
      Views

      Thanx, it really solved my problem
    • SOLVED how to parent qpainter (code) to QTabWidget (Design Mode)
      General and Desktop • qtablewidget qpainter qt5.6 qmainwindow parent • • pauledd  

      13
      0
      Votes
      13
      Posts
      4940
      Views

      @pauledd :) class MyWidget : public QWidget << yes that is subclassing :) Also, a widget can only paint on it self. its not possible to paint on other widget from inside a paintevent. Thats why the first sample didnt work. You asked painter to paint on tab from inside mainwindows paintEvent :) I guess you already found out but its just to make clear for other readers.
    • UNSOLVED Glyph width information is inconsistent in PDF
      General and Desktop • qpainter qprinter pdf • • euchkatzl  

      2
      0
      Votes
      2
      Posts
      762
      Views

      Hi, You should check the bug report system to see if it's something known. If not please consider opening a new report providing your example and as many details as possible about your setup.
    • SOLVED QPainter fill rectangle with gradient
      General and Desktop • qpainter gradient • • beecksche  

      3
      0
      Votes
      3
      Posts
      2876
      Views

      @mrjj Yeah make sense. Thanks!
    • SOLVED QPainter.begin returns false on prod machine
      General and Desktop • windows qpainter qprinter pdf qt5.2.1 • • PierreFIL  

      11
      0
      Votes
      11
      Posts
      3197
      Views

      OK, so now that I have launched the program with admin rights and came back with user session, the application is working (?!?) So it was neither a DLL or plugins problem, but just a weird right access blocking. I am sad I can't explain why I had to launch it once with admin session, but at least I am glad I solved my problem. Thanks anyway to those who give their time to help.
    • SOLVED QPainter trick .
      General and Desktop • qpainter • • Walux  

      6
      0
      Votes
      6
      Posts
      1583
      Views

      @Walux :-)
    • UNSOLVED How to draw a horizontal line??
      General and Desktop • qpainter • • NIXIN  

      2
      0
      Votes
      2
      Posts
      3290
      Views

      There are a couple of errors here and some weird unused code. Lets go over it: setGeometry: Unable to set geometry (...) - this is just a warning. A widget has a 0 minimum size and minimum size hint by default. You used a layout on it so it has some margins (11 px in this case) Because of the frame of the window a window manager can't create a window that small so it resizes it to a smallest possible size and lets you know with a warning. To fix it either use setMinimumSize() or override minimumSizeHintfor your widget. QPainter related messages - you're creating a painter as a class member variable. Don't do that. Create the painter locally in the paint event with a proper surface to use it on: void DrawLine::paintEvent(QPaintEvent *) { QPainter p(this); //paint using p ... There's no such thing as a lineEvent() - what is that? What's the layout for? Are you gonna put something in it? If yes then remember that it will obscure whatever you paint in your paint event. You're not deleting the dLine variable in main(). It's leaking. Either create it on the stack (which is the easiest and recommended), set a Qt::WA_DeleteOnClose attribute on it or delete it manually after the a.exec() call returns (pointless manual work). just a hint - when overriding virtual methods use override specifier. It will save you a lot of typo related bugs: void paintEvent(QPaintEvent *); //compiles fine and overrides the base implementation void pAintEvent(QPaintEvent *); //compiles fine and never gets called because of a typo void pAintEvent(QPaintEvent *) override; //doesn't compile and lets you know. yay!
    • SOLVED Use QPainter with QPixmap contain QImage
      General and Desktop • qpainter qimage qpixmap • • kevin32  

      6
      0
      Votes
      6
      Posts
      5961
      Views

      @kevin32 Great :)
    • UNSOLVED Draw a line in Scene (not adding)
      General and Desktop • qpainter scene draw • • AlvaroS  

      6
      0
      Votes
      6
      Posts
      2013
      Views

      @AlvaroS ok. seems a bit messy. Do you really need a QGraphicsScene then ? You could also draw it as a custom control. you need zooming etc ? In any case, did u see this example http://doc.qt.io/qt-5/qtwidgets-graphicsview-diagramscene-example.html it even has arrowhead class :)