Unsolved Draw big things with Painter outside main window.
-
Hey, is it possible to draw things outside main window? I have an really big pattern to draw but I cant because of it's too big / window is too small. Is it possible?
-
@BD9a You can only draw on a widget, so, no you can't draw outside of your window. Why would you need to draw outside of the window? Just draw what currently fits in your window.
-
Hi
Yes it is possible if you use a QPixmap.https://forum.qt.io/topic/108442/how-to-paint-to-pixmap/2
But if it is to show to the user, then you should either use a ScrollArea so the user can scroll around to see if all
or simply draw in a scaled version that fits the window. -
@jsulm The problem is that sometimes my pattern is a lot bigger than window (I have an "ScrollArea / Drag option to see it all)
@mrjj Will test this QPixmap, thanks. As I said I have an "ScrollArea / Drag option to see it all, but what about "scaled version"? I saw there's Painter->setScale(), but it doesnt work for me properly(?) (cant see "image" after that option)
-
Hi
How do you currently draw the pattern -
Im using painter->drawPoint(row, col); in loop (looping through file containing data) in a paint() function (from QQuickPaintedItem).
-
@BD9a
Hi
Well drawpoint is affected by scale() so maybe the scale values was just too muchvirtual void paintEvent(QPaintEvent *event) override { QPainter p(this); QPointF list[] = {{0,0}, {20,20}, {30,30}}; p.setPen(QPen(Qt::red)); p.scale(0.5,0.5); p.drawPoints(list,3); }
clearly makes the half the size but maybe your use case if differnt.
-
@mrjj
In QQuickPaintedItem there's no paintEvent that I can override. If it does matter, Im using C++ Object in QML to display it. -
I'm don't think it matter since QQuickPaintedItem has paint.
But did you try to with like scale (0.5,0.5) and see if that affects it ?
-
@mrjj
Yeah, when I had problem with this I placed painter->scale(0.5, 0.5); in loop, I dont know why. Now I placed it before loop and it's working, but the problem is when the pattern is small. When I tried to "back" to original scale in QML (from 0.5 in C++ to 2.0 in QML) the image is blurry. I will try to do pattern size detection and then - if pattern is big scale is down, if pattern is small then do nothing / scale it up.