<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Combine several images into one?]]></title><description><![CDATA[<p dir="auto">I've been using PyQt5 for just a few days but I'm doing pretty well except for one thing I just can't figure out.</p>
<p dir="auto">I have three images (parts of a whole) that I want to combine into one. I tried various things but messed up every time. The most promising looks like QPainter but I can't seem to figure out the arguments and I can't find any simple examples online anywhere.</p>
<p dir="auto">Anyway, I have three images but to start I'm trying with just one like this:</p>
<pre><code>		for part in self.parts:
			_width += part.width()
		
		_img = QPixmap(_width,self.SrcImg.height())
</code></pre>
<p dir="auto">So the target image is full size of the three combined. To start I'm only trying to get one image painted onto it but that's failing miserably no matter what I try. Here's what I thought it should look like after reading the docs</p>
<pre><code>		painter = QPainter(_img)
		painter.setCompositionMode(QPainter.CompositionMode_SourceAtop)		
		painter.drawImage(0,0,self.parts[0])
</code></pre>
<p dir="auto">But that gives an error:<br />
painter.drawImage(0,0,self.parts[0])<br />
TypeError: arguments did not match any overloaded call:<br />
drawImage(self, QRectF, QImage): argument 1 has unexpected type 'int'<br />
drawImage(self, QRect, QImage): argument 1 has unexpected type 'int'</p>
<p dir="auto">So I tried making a QRect(0,0,self.parts[0].width,self.parts[0].height()) but then the error just changes from type int to type QRect</p>
<p dir="auto">It looks really simple but I'm just not getting it for some reason</p>
]]></description><link>https://forum.qt.io/topic/140835/combine-several-images-into-one</link><generator>RSS for Node</generator><lastBuildDate>Fri, 25 Sep 2026 01:18:15 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/140835.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 17 Nov 2022 22:52:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Combine several images into one? on Fri, 18 Nov 2022 06:25:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/pmeloy">@<bdi>pmeloy</bdi></a> said in <a href="/post/736677">Combine several images into one?</a>:</p>
<blockquote>
<p dir="auto">QRect(0,0,self.parts[0].width,self.parts[0].height())</p>
</blockquote>
<p dir="auto">Please take a closer look at that line: it is quite apparent what is wrong here (hint: self.parts[0].width).</p>
]]></description><link>https://forum.qt.io/post/736698</link><guid isPermaLink="true">https://forum.qt.io/post/736698</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Fri, 18 Nov 2022 06:25:32 GMT</pubDate></item></channel></rss>