Navigation

    Qt Forum

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

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

      7
      0
      Votes
      7
      Posts
      243
      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 Live camera image using OpenCV showing in Qlabel crashes due to out of memory error
      General and Desktop • gui qimage opencv c++ qt qpixmap • • Imran Hassan  

      9
      1
      Votes
      9
      Posts
      190
      Views

      Thank you all guys. Your suggestions and expert opinion helped a lot with solving the problem. QT forum is always so helpful. After trying many things here is the conclusion and code is now working perfectly fine I removed the tic toc part time(&start); timer = double(getTickCount()); tic(); It was working but crashing then just to make sure that QImage is not NULL I removed the img = QImage(); // releasing memory with if(!img.isNull()) img = QImage(); Its working perfectly fine now.
    • SOLVED How to display .dds files
      General and Desktop • qimage qpixmap dds • • Matthieuzone  

      13
      0
      Votes
      13
      Posts
      163
      Views

      @Bonnie Thank you very much, it worked perfectly.
    • SOLVED QfileDialog::Getopenfilename does not open the second time and after
      General and Desktop • qimage qpixmap qfiledialog • • aramaz  

      3
      0
      Votes
      3
      Posts
      61
      Views

      @Bonnie said in QfileDialog::Getopenfilename does not open the second time and after: Remove that static. Static local variables Variables declared at block scope with the specifier static or thread_local (since C++11) have static or thread (since C++11) storage duration but are initialized the first time control passes through their declaration (unless their initialization is zero- or constant-initialization, which can be performed before the block is first entered). On all further calls, the declaration is skipped. So with the static keyword, getOpenFileName will only be called at the first time. Thanks! I just realized that I should not have copy pasted that line of code without looking at it closer. Cheers.
    • UNSOLVED QScrollArea not expanding when QPixmap is loaded
      General and Desktop • qlabel qpixmap qscrollarea • • Conical  

      3
      0
      Votes
      3
      Posts
      48
      Views

      Hi, How did you set the QLabel on your QScrollArea ? If you put it in a layout on the scroll area then that's wrong.
    • UNSOLVED Setting QPixmap to Qlabel gives segmentation fault and app crashes
      General and Desktop • qt5 qimage qlabel qpixmap gstreamer1.0 • • vicky_mac  

      22
      0
      Votes
      22
      Posts
      266
      Views

      Rather than giving the pointer to your MainWindow instance, pass directly the pointer to your label. Basically: mainwindow->ui->label
    • 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 Draw basic Axes on QPixmap ?
      General and Desktop • qlabel qpixmap qchart plot axis • • R-P-H  

      29
      0
      Votes
      29
      Posts
      1014
      Views

      Thanks for the support guys. I tried making a transparent QPixmap image using Qt::transparent fill for the axis and overlaying it onto my other QPixmap, however it didn't work properly. So I ended up just drawing directly onto the image itself. Not the most efficient method but it seems to work...
    • UNSOLVED Scaling pixmap images in qscrollarea
      General and Desktop • qlabel qpixmap qscrollarea • • rjmoses  

      4
      0
      Votes
      4
      Posts
      128
      Views

      @rjmoses Yes it will scale all images to match IconSize.
    • SOLVED Crop pixmap from qgraphicsscene with qgraphicsItem
      General and Desktop • qgraphicsscene qgraphicsitem qpixmap • • sayan275  

      6
      0
      Votes
      6
      Posts
      820
      Views

      Hi, I got the expected output from grab(QRect) https://stackoverflow.com/questions/16362191/qt-grab-widget-and-save-image m_graphicsView->grab(rect).save("OUT.jpg"); Thanks all.
    • SOLVED QPixmap size limit
      General and Desktop • qpixmap size • • Gianluca86 0  

      6
      0
      Votes
      6
      Posts
      246
      Views

      @mrjj Thanks for the help
    • SOLVED How can I set timer in order to change the picture in the label in Qt
      General and Desktop • qt5.5 qpixmap qtimer timer • • greencow  

      5
      0
      Votes
      5
      Posts
      984
      Views

      @dheerendra Okay, done, thank you for reminding!
    • 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 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.
    • SOLVED Returning QByteArray as Qvariant
      General and Desktop • qpixmap qvariant qbytearray return • • Euclide  

      8
      0
      Votes
      8
      Posts
      2135
      Views

      I found where the problem was! As Christian Ehrlicher said according to the Documentation QByteArray::fromRawData() only store the pointer to the data. That explain why it doensn't work outside the function since the data goes out of scope. Instead of using this method I used one the constructors that make deep copy of the data. And it just works fine! QByteArray data (value.dataPointer (), value.dataSize ()); return data; Thanks all!
    • UNSOLVED Drawing Images in Widget PaintEvent using existing buffer
      General and Desktop • qwidget qimage qpixmap paint event • • SilverSurfer  

      2
      0
      Votes
      2
      Posts
      1193
      Views

      Hi, See my answer one the other thread.
    • SOLVED QPixmap or QImage for JFIF image format
      General and Desktop • qimage qpixmap jpeg jfif • • scottnat  

      8
      0
      Votes
      8
      Posts
      2284
      Views

      Why create a QList and not do the conversion directly after calling CaptureImage ? Otherwise, does the library you are using to get the image provide a streaming API ?
    • UNSOLVED How to maintain aspect ratio of a Qlabel throughly??
      General and Desktop • qlabel qpixmap qt 5.9 • • vasu_gupta  

      1
      0
      Votes
      1
      Posts
      1023
      Views

      No one has replied

    • UNSOLVED QPixmap::fromImage(img) sometime crash.
      General and Desktop • qimage qpixmap • • mosleim  

      6
      0
      Votes
      6
      Posts
      3396
      Views

      Hi, Can you show how your create the image that you pass to the function ? Also, can you provide a stack trace of your application crash ?
    • UNSOLVED How to save the widget containing pixmap which keep changing at certain time interval, as an image file.
      General and Desktop • qwidget qpixmap grab • • NIXIN  

      8
      0
      Votes
      8
      Posts
      2276
      Views

      Yes, a file with size 0 kb is being created
    • UNSOLVED Modifying Images
      Game Development • qgraphicsview qgraphicsscene qimage qpixmap qgraphicspixmap • • Axator  

      9
      0
      Votes
      9
      Posts
      3034
      Views

      What do you think about this? int length = this->boundingRect().width(); length = (int)(((double)length * (double)value) / 100.0); QPixmap pix(this->boundingRect().width() - length, this->boundingRect().height()); pix.fill(Qt::transparent); QPainter p; p.begin(&pix); p.fillRect(pix.rect(), QColor(0, 0, 0, 120)); p.end(); gauge->setPixmap(pix); gauge->setPos(pos().x()+length, pos().y()); It works fine and the effect is the same as on example pixtures above.
    • UNSOLVED Qt3D Custom FrameGraph: Surface
      General and Desktop • qt3d qpixmap qt5.7.0 qsurface • • Neosw  

      2
      0
      Votes
      2
      Posts
      1157
      Views

      I have find a way to get a QImage of an QWindow: Make a standard QWindow with is surface and add the following code: // set the current context OpenGL // check if an OpenGlContext is created QOpenGLContext context; context.setFormat(format()); if (!context.create()) qFatal("Cannot create the requested OpenGL context!"); context.makeCurrent(this); // init a new framebuffer QOpenGLFramebufferObjectFormat fboFormat; fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); fboFormat.setMipmap(true); fboFormat.setSamples(4); fboFormat.setTextureTarget(GL_TEXTURE_2D); fboFormat.setInternalTextureFormat(GL_RGB); resize(this->width(), this->height()); const QRect drawRect(0, 0, this->width(), this->height()); const QSize drawRectSize = drawRect.size(); _fbo = new QOpenGLFramebufferObject(drawRectSize, fboFormat); _fbo->bind(); ... _fboImage = new QImage(_fbo->toImage(false)); But, this is work only if the window is "visible", when it is set to Hidden the rendering of Qt3D was made (the rendering loop, because the GPU is used and the FPS is divided by 3), but the QOpenGLFramebufferObject was not filled :/ Do you have any idea of how force the filling of the fbo ? PS: I have found this here : http://stackoverflow.com/questions/17221730/do-offscreen-renderopengl-with-qt5
    • UNSOLVED QPixmap: How to render?
      General and Desktop • qpixmap qtextedit rendering • • HenrikSt.  

      6
      0
      Votes
      6
      Posts
      3676
      Views

      The QPixmap class has a constructor that takes a QSize parameter and therefore allows you to create a pixmap of a given size. That is what @jsulm is doing in the first line of his last code example. Documentation.
    • UNSOLVED Need help optimizing the design of an image editor program
      General and Desktop • image qimage qlabel qpixmap image processin • • Wings  

      2
      0
      Votes
      2
      Posts
      1074
      Views

      Hi, QPainter can draw a QImage. So you can for example create a new Widget, subclass for QLabel for example if you want and reimplement paintEvent. Like this you work all the time with your QImage without creating another one. And better you can only update the region that changed, no need to refresh everything. I did not try it but it should work. Sincerely
    • UNSOLVED Contert int matrix to QPixmap
      General and Desktop • qpixmap scene matrix • • AlvaroS  

      2
      0
      Votes
      2
      Posts
      1150
      Views

      Hi! The way to convert your matrix to a QPixmap is to convert it to QImage first (e.g. using void QImage::setPixel(const QPoint &position, uint index_or_rgb)) and then convert the QImage to a QPixmap (using [static] QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags = Qt::AutoColor)).
    • SOLVED Use QPainter with QPixmap contain QImage
      General and Desktop • qpainter qimage qpixmap • • kevin32  

      6
      0
      Votes
      6
      Posts
      7425
      Views

      @kevin32 Great :)
    • UNSOLVED How to add icon to multi button in simple way?
      General and Desktop • qpixmap qicon • • MhM93  

      5
      1
      Votes
      5
      Posts
      1253
      Views

      @Rohith : thanks.but your solution does not work for me. I have multi button. I for example want to set image (/pic/1.png) to btn1 and then set another image to another button. My question How to set image to them in my code behind?
    • UNSOLVED Bug in Qt >= 5.4 when drawing QPixmap onto QOpenGLPaintDevice
      General and Desktop • opengl qpixmap bug drawpixmap glbindtexture • • matejtomcik  

      4
      0
      Votes
      4
      Posts
      1629
      Views

      @SGaist Hi, I'm running Windows 10, OpenGL 4.5.0
    • UNSOLVED QImage in QGraphicsScene is pixelated when zooming in
      General and Desktop • qgraphicsscene qpixmap svg pixelated • • alogim  

      2
      0
      Votes
      2
      Posts
      1535
      Views

      hi As far as I know there is no build in raster to vector conversion. Also many images are not really good for it. Im wonder if QGraphicsScene is scaling images with best quality. http://stackoverflow.com/questions/22652491/qt-resize-image-with-best-quality
    • [Solved] QIcons are not shown in binary, while shown when compiled from source
      General and Desktop • cmake qpixmap qicon binary • • viruca  

      7
      0
      Votes
      7
      Posts
      1855
      Views

      @hskoglund You were right! Thank you.
    • UNSOLVED Graphics glitch in QLabel (showing old image data when calling setText())
      General and Desktop • qlabel qpixmap x11 • • bepaald  

      5
      0
      Votes
      5
      Posts
      1815
      Views

      Thanks for the reply. This is using intel graphics, and unfortunately your workaround does not help. After your message, I've tested the same code from a newer live image and also on my more up-to-date laptop (which has similar hardware) and I can not reproduce the issue in either of these cases. On the affected machine, I tried updating the intel driver and mesa, but this did not solve it, so I guess it probably needs the kernel or qt packages updated as well. Unfortunately, this is not an option at this point. I've worked around the issue by re-implementing paintEvent() to do something like the following if (no_pixmap_set) { pos = calculateTextPosition() QPainter::drawText(pos, text); return; } QLabel::paintEvent(event); Which seems to work just fine. In fact, re-implementing the paintEvent has given me the chance to animate the image changes which looks pretty nice, and it will be easy to simplify the code a bit when all my machines are fully updated and the glitch is gone. Thanks again!
    • SOLVED Scaling QPixmap to fit Label
      General and Desktop • qpixmap scaling • • gabor53  

      4
      0
      Votes
      4
      Posts
      19717
      Views

      Thank you. Both worked though I guess it is supposed to be int w = ui->label->width (); int h = ui->label->height (); ui->label->setPixmap (pix.scaled (w,h,Qt::KeepAspectRatio));
    • UNSOLVED Tinting a QPixmap using QPainter (CompositionMode_Overlay)
      General and Desktop • qtcreator qt5 qpainter qpixmap qcolor • • Votato  

      7
      0
      Votes
      7
      Posts
      5454
      Views

      @Matt-Chaput said: It seems odd for a moderator to be so belligerent, and act so condescending I'm sorry you feel that way but there's nothing I can do about it. I did try to provide a solution and explain why the other one was incorrect mathematically. Overlay mode would be useful for tinting e.g. icons with color, except it writes over transparent areas. That shortcoming of overlay mode is exactly the reason I suggested a two step approach instead. It breaks the problem into an alpha step and a color step. To be useful, it should multiply the alpha of the source and destination. If you wanted to do it in one step, yes. But, since there's no such mode in Qt, you can use the two step approach I suggested. First is the original. Second is the mask created using the alpha of the source (CompositionMode_SourceIn). Third is the final result using overlay with the mask (CompositionMode_Overlay). As far as I can tell this is the result OP wanted, so can you explain what I got wrong? There's nothing sensible about Qt is doing. Qt is providing a pretty common set of composition modes implemented by various APIs, described e.g. here, here and here. If you know of a graphics API that does SourceIn+Overlay in one step could you point us to it?
    • UNSOLVED How to get mouse press event on a QPixmap
      General and Desktop • qpixmap mousepressevent qgraphicspixmap • • EarthHobbit  

      2
      0
      Votes
      2
      Posts
      2815
      Views

      @EarthHobbit Hi This sample works for me (i can click it ) #include <QApplication> #include<QGraphicsScene> #include<QGraphicsDropShadowEffect> #include<QGraphicsPixmapItem> #include<QMessageBox> #include<QGraphicsView> class myGraphicsPixmapItem: public QGraphicsPixmapItem { public: myGraphicsPixmapItem(QPixmap pixmap): QGraphicsPixmapItem(pixmap) { }; ~myGraphicsPixmapItem() { }; void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) { QMessageBox::information(NULL, "Information!", "Mouse release Detected!"); }; }; int main(int argc, char* argv[]) { QApplication app(argc, argv); QGraphicsScene scene; QPixmap pix(200, 200); QPainter* paint = new QPainter(&pix); paint->setPen(QColor(255, 34, 255, 255)); paint->drawRect(0, 0, 200, 200); myGraphicsPixmapItem* pixmapItem = new myGraphicsPixmapItem(pix); pixmapItem->setFlags(QGraphicsItem::ItemIsMovable); delete paint; QGraphicsView view(&scene); scene.addItem(pixmapItem); view.showFullScreen(); return app.exec(); }
    • SOLVED High CPU usage when saving QList<QPixmap>
      General and Desktop • qpixmap • • iamqt  

      10
      0
      Votes
      10
      Posts
      2643
      Views

      @iamqt I agree. Since it will really depends on user machines. I use ramdisk for saving so it is very fast, where old hd will take a long time. Besides I user makes full HD animation with 1000 frames, I assume he do know it is a bit heavy :)
    • SOLVED QNetworkAccessManager Download Image
      General and Desktop • qpixmap qnetworkaccessm • • elveatles  

      5
      0
      Votes
      5
      Posts
      1832
      Views

      Printing out thumbnailData.data(), I get: 302 Found The resource was found at https://... So I realize my problem now. The thumbnail url is redirecting me to another url which is what I actually want to use to download for the QPixmap. Thanks for your help everyone.
    • Resize width of QPixmap without scale
      General and Desktop • qpixmap • • Blakoli  

      4
      0
      Votes
      4
      Posts
      4026
      Views

      You're welcome ! Since you have it working now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)
    • QLabel pixmap not clearing
      General and Desktop • qlabel qpixmap transparency qt 4.8 • • Tymer  

      1
      0
      Votes
      1
      Posts
      1803
      Views

      No one has replied

    • [SOLVED] Problem with QPixmap scaled
      General and Desktop • qpixmap scale • • fermatqt  

      5
      0
      Votes
      5
      Posts
      7267
      Views

      ah ok. Good to know that it will (try) to scale an image to 0,0 :) Remember to flag as solved if your happy.
    • Constantly generating QPixmap* fails after a number of iterations
      General and Desktop • qimage qpixmap qhash • • skats  

      4
      0
      Votes
      4
      Posts
      1276
      Views

      Just don't create it on heap. QPixmap is implicitly shared. It does not matter how you create pixmap. What does is total number of allocated resources. Changes to your code might fix something if your previous code did not clean the memory -did not delete pixmap. So code causing problem was not posted.