qpixmap

How to make qt qgraphicsview scale to not affect stipple pattern?

梦想的初衷 提交于 2019-12-05 06:01:30
I draw few rectangles inside the QGraphicsView ; I use custom stipple pattern for these by creating a QBrush with my QPixmap . This gets displayed with the default zoom level as expected. When I call view->scale() , the rectangles show up bigger or smaller as I expected. However Qt has scaled the individual bits of the stipple pattern which is not expected; I expected it to draw the larger or smaller rectangle again with the brush. Eg. If I had used a stipple pattern with one pixel dot and pixel space, after zooming in, I want to see a larger rectangle but I want the same stipple pattern with

Make a pixmap transparent for a QLabel

坚强是说给别人听的谎言 提交于 2019-12-05 02:44:48
问题 I have a MainWindow with a QLabel and a pixmap. I want to make it transparent (or less opaque) I am using the following code below. ui->label->setAttribute(Qt::WA_TranslucentBackground); ui->label->repaint(); However it does not seem to work. The image looks the same without any changes. I also tried to use to the following statement: ui->label->setStyleSheet("background-color: rgba(255, 255, 255, 10);"); Unfortunately, this does not seem to work either. Anyone knows how can I make an image

Getting a HBITMAP from a QPixmap in QT5 (Windows)

核能气质少年 提交于 2019-12-05 01:08:07
Now that QPixmap::toWinHBITMAP() has been deprecated, I can't find a way to get an HBITMAP from a QPixmap (or QImage). Googling, I found there's a function called qt_pixmapToWinHBITMAP() which seems would do what I need, but I can't find what module I should enable -if any- in my .pro file or what header I should include to use it, or perhaps something else. The reason I need a HBITMAP is to create a video using VFW. Of course, I'd love to be able to do that using only Qt. There's the QtMultimedia module, but as far as I can tell it doesn't export video, so I guess I'm stuck with using the

Trouble displaying sequence of images with setPixmap in Qlabel

牧云@^-^@ 提交于 2019-12-04 18:31:18
I'm trying to display a sequence of images through a Qlabel using setPixmap. I have a QStringList containing the image file names and a for loop which iterates through the images with a 5 second wait after each image. However, only the last image file is ever being displayed. Currently the screen remains blank during the wait of the first iterations until the last image is finally shown. I've read that using a for loop wont work and that I should be using signals and slots instead. I'm new to this concept though and I would really appreciate an example to point me in the right direction. Here

QPixmap and SVG

青春壹個敷衍的年華 提交于 2019-12-04 18:27:39
How would you suggest to handle svg with QPixmap? The construct QPixmap(":/myfile.svg"); then call of scaled() does not work. The QPixmap gets pixelised. Thx. You should use SVGRenderer to render it onto a QImage . From there you can convert to a QPixmap with QPixmap::convertFromImage . Now there is much simpler way without needing of SVG module QIcon("filepath.svg").pixmap(QSize()) So simple and works fine. Atleast in my case it worked. Something like that: QSvgRenderer renderer(svg_file_name); QPixmap pm(width, height); pm.fill(fill_color); QPainter painter(&pm); renderer.render(&painter, pm

High performance QImage output to display

廉价感情. 提交于 2019-12-04 12:57:37
I'm trying to make video output (sequence of frames) to any qt visible widget. At beginning i thought that QLabel will be enough for this point... but i was wrong. Converting to pixmap is too overloading for processor at large images: 1080p for example. Any other solution? (not QLabel?) Example of code for one frame: QImage m_outputFrameImage(width, height, QImage::Format_RGB888); memcpy(m_outputFrameImage.bits(), m_frameRGB->data[0], height * width * 3); QPixmap pixmap = QPixmap::fromImage(m_outputFrameImage); // BAD, slow and high load /* Bad too (Same code?) QPainter painter; painter.begin(

How to show pixel position and color from a QGraphicsPixmapItem

百般思念 提交于 2019-12-04 10:36:27
I'm developing a custom widget with QGraphicsScene/View and I have no prior experience with it. The custom widget is an image viewer that needs to track mouse movement and send signal(s) to it's parent dialog / window. The signal(s) will be the position of the pixel under the mouse cursor and it's color (in RGB). A status bar will use that information. I use a QGraphicsPixmapItem to display the image I load from a file in the scene. Thanks. First of all you have to implement the mouseMoveEvent in your custom item. In this function you can easily get the mouse position calling the pos function.

Convert PyQt5 QPixmap to numpy ndarray

限于喜欢 提交于 2019-12-04 09:36:41
I have pixmap: pixmap = self._screen.grabWindow(0, self._x, self._y, self._width, self._height) I want to convert it to OpenCV format. I tried to convert it to numpy.ndarray as described here but I got error sip.voidptr object has an unknown size Is there any way to get numpy array (same format as cv2.VideoCapture read method returns)? ingvar I got numpy array using this code: channels_count = 4 pixmap = self._screen.grabWindow(0, self._x, self._y, self._width, self._height) image = pixmap.toImage() s = image.bits().asstring(self._width * self._height * channels_count) arr = np.fromstring(s,

Shifting the hue of a QImage / QPixmap

亡梦爱人 提交于 2019-12-04 08:30:54
I suppose this is more of a graphics manipulation question in general, but I'd like to accomplish this in Qt (c++). If I have an image - let's just say a circle on a transparent background - of a light gray color, is there any built-in functionality in Qt to shift the hue / saturation to color it? I suppose I could go pixel by pixel, and modifying the rgb mathematically - add x to r, g, and b, to get a desired color, but there must be a better way than modifying every single pixel. Nothing in the Qt Docs goes this far into image manipulation, just altering alpha and colors. Should I look into

threading: It is not safe to use pixmaps outside the GUI thread

半腔热情 提交于 2019-12-04 07:52:12
I'm building a music player, that checks the status with SqueezePlay, which is a SqueezeBox controller app. To cut a long story short, I'm checking the status of Squeezeplay ever 5 seconds by using threading. If the song title changes, I let it update the labels (Qlabel, album artwork (QPixmap), etc. However, when I ask it to update it via threading, I'm getting It is not safe to use pixmaps outside the GUI thread . How can I do threading but still set the QPixmap? Sample code: #self.sq.getArtwork() returns variable with the image coverArt = self.sq.getArtwork() coverPixMap = QtGui.QPixmap()