<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Isti&#039;s Blog &#187; QT Programming</title>
	<atom:link href="http://www.xistix.com/blog/category/qt-programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.xistix.com/blog</link>
	<description>Tutorials, examples, 42</description>
	<lastBuildDate>Wed, 06 Jul 2011 12:30:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>A QT Project &#8211; Fractal Generator &#8211; Save and Load</title>
		<link>http://www.xistix.com/blog/2009/01/08/a-qt-project-fractal-generator-save-and-load/</link>
		<comments>http://www.xistix.com/blog/2009/01/08/a-qt-project-fractal-generator-save-and-load/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 09:18:06 +0000</pubDate>
		<dc:creator>Isti</dc:creator>
				<category><![CDATA[Arthur Fractal Generator]]></category>
		<category><![CDATA[QT Programming]]></category>
		<category><![CDATA[finish]]></category>
		<category><![CDATA[load]]></category>
		<category><![CDATA[save]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.kultatech.com/blog/?p=240</guid>
		<description><![CDATA[So far I was not a great finisher. I mean I usually didn&#8217;t finish my personal projects. After solving the challenging parts, I usually loose interest and abandon the project. I decided I will change and I will finish Arthur. If you followed this blog you might remember that the original goal was to get [...]]]></description>
			<content:encoded><![CDATA[<p>So far I was not a great finisher. I mean I usually didn&#8217;t finish my personal projects. After solving the challenging parts, I usually loose interest and abandon the project. I decided I will change and I will finish Arthur. If you followed this blog you might remember that the original goal was to get familiar with QT and not to write a full featured fractal generator. I think this mission is completed now, but the program itself was missing some crucial parts. Especially saving and loading the fractals. You could already save the generated images earlier, but you could not load the fractal for further editing. I really thought is is boring to write some code to save and load the necessary data. I can tell you it was boring <img src='http://www.xistix.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  However I feel better now, since I have a more or less completed program.</p>
<p>OK. To make the boring stuff a bit more interesting I decided that I will store the fractal data in XML format. There is no particular reason for that apart from the fact that I am a great fan of XML. However it was a good opportunity to have a look at the XML library in QT. Yeah, nothing special. The usual stuff. If you used other XML libraries before, everything will be familiar.</p>
<p>While thinking what data I should actually save I faced a problem with the palette. Actually I was thinking whether I should save the palette or just a reference to the palette file. Finally I decided to put the palette to the fractal description file. This way it is easier it share fractal files, since everything is packed to one file. As a side effect I introduced a very simple XML format for the palette and added a new feature to Arthur that one can load the palette of a fractal.</p>
<p>From now on I will not develop Arthur further until someone starts begging to me to do so <img src='http://www.xistix.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I admit there might be lots of design issues with it (it wasn&#8217;t actually designed eh eh) and it is far from industrial quality, but it was not the aim. I learned quite much about QT while I was making it and I hope some parts of it can be used as examples to solve your problems.</p>
<p>You can get the sources from here: <a href="http://www.kultatech.com/blog/wp-content/uploads/2009/01/fractal017.tgz">fractal017</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xistix.com/blog/2009/01/08/a-qt-project-fractal-generator-save-and-load/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A QT Project &#8211; Fractal Generator &#8211; Newton</title>
		<link>http://www.xistix.com/blog/2008/12/15/a-qt-project-fractal-generator-newton/</link>
		<comments>http://www.xistix.com/blog/2008/12/15/a-qt-project-fractal-generator-newton/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 07:14:34 +0000</pubDate>
		<dc:creator>Isti</dc:creator>
				<category><![CDATA[Arthur Fractal Generator]]></category>
		<category><![CDATA[QT Programming]]></category>
		<category><![CDATA[newton]]></category>

		<guid isPermaLink="false">http://www.kultatech.com/blog/?p=226</guid>
		<description><![CDATA[I added two new fractals to Arthur. They are both calculated with Newton&#8217;s method, that is: z -&#62; z &#8211; f(z) / f&#8217;(z) Newton invented this formula to estimate roots of functions. The initial z is an estimation of the root. The calculated z is closer to the root that is a better estimation. If [...]]]></description>
			<content:encoded><![CDATA[<p>I added two new fractals to Arthur. They are both calculated with Newton&#8217;s method, that is:<br />
z -&gt; z &#8211; f(z) / f&#8217;(z)<br />
Newton invented this formula to estimate roots of functions. The initial z is an estimation of the root. The calculated z is closer to the root that is a better estimation. If we calculate the formula iteratively, z converges to one of the roots of f(z).</p>
<p>My newton fractals are colored according to the number of necessary iterations to get in a predefined distance with z from one of the roots.</p>
<p>The newton001 fractal is using the f(z) = z^3 &#8211; 1 polynomial.<br />
f&#8217;(z) = 3z^2</p>
<p>z -&gt; z &#8211; f(z) / f&#8217;(z) = z &#8211; (z^3 &#8211; 1) / 3z^2 = (2z^3 + 1) / 3z^2</p>
<p>The roots of f(z) are: 1, -0.5 + 0.86603i and -0.5 &#8211; 0.86603i</p>
<p>Here is an image of the fractal:</p>
<p><a href="http://www.xistix.com/blog/wp-content/uploads/2008/12/newton001.jpg"><img class="alignnone size-medium wp-image-228" title="newton001" src="http://www.kultatech.com/blog/wp-content/uploads/2008/12/newton001-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>The newton002 fractal is using the f(z) = z^4 &#8211; 1 polynomial<br />
f&#8217;(z) = 4z^3</p>
<p>z -&gt; z &#8211; f(z) / f&#8217;(z) = z &#8211; (z^4 &#8211; 1) / 4z^3 = (3z^4 + 1) / 4z^3</p>
<p>The roots of f(z) are: 1, i, -1 and -i</p>
<p>Here is an image of the fractal:</p>
<p><a href="http://www.xistix.com/blog/wp-content/uploads/2008/12/newton002.jpg"><img class="alignnone size-medium wp-image-229" title="newton002" src="http://www.kultatech.com/blog/wp-content/uploads/2008/12/newton002-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>You can get the newest sources of Arthur from here: <a href="http://www.kultatech.com/blog/wp-content/uploads/2008/12/fractal016.tgz">fractal016</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xistix.com/blog/2008/12/15/a-qt-project-fractal-generator-newton/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>QT &#8211; undefined reference to vtable</title>
		<link>http://www.xistix.com/blog/2008/12/12/qt-undefined-reference-to-vtable/</link>
		<comments>http://www.xistix.com/blog/2008/12/12/qt-undefined-reference-to-vtable/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 07:15:18 +0000</pubDate>
		<dc:creator>Isti</dc:creator>
				<category><![CDATA[QT Programming]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[moc]]></category>
		<category><![CDATA[QT]]></category>
		<category><![CDATA[signals]]></category>
		<category><![CDATA[slots]]></category>
		<category><![CDATA[vtable]]></category>

		<guid isPermaLink="false">http://www.kultatech.com/blog/?p=218</guid>
		<description><![CDATA[I&#8217;m frequently checking the statistics of this blog. I have found that a vast amount of visitors are finding my blog when they are searching for solution to the &#8220;undefined reference to vtable&#8221; error in QT. I thought it worts to write a summary about this error and the possible solutions. Don&#8217;t panic! Usually this [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m frequently checking the statistics of this blog. I have found that a vast amount of visitors are finding my blog when they are searching for solution to the &#8220;<span style="color: #ff6600;">undefined reference to vtable</span>&#8221; error in QT. I thought it worts to write a summary about this error and the possible solutions.</p>
<p>Don&#8217;t panic!</p>
<p>Usually this error pops up when you have a moc compiler related error. The moc compiler is a QT compiler tool. QT is extending the C++ language by some macros and non C++ language elements like signals slots etc. In order to compile the QT programs with a C++ compiler, these files which contain non C++ elements need preprocessing. The moc compiler should find and process all header files which has QT specific stuff especially signals and slots.</p>
<p>First thing to try:</p>
<p><span style="color: #ff6600;">make clean</span><br />
manually remove all generated files especially which has suspicious &#8216;moc&#8217; in their names <img src='http://www.xistix.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  if make didn&#8217;t do that<br />
<span style="color: #ff6600;">rm Makefile</span><br />
<span style="color: #ff6600;">qmake</span><br />
<span style="color: #ff6600;">make</span></p>
<p>OK if the problem still exist, <span style="color: #ff6600;">check the project file (*.pro)</span></p>
<p>Make sure that all header files which contain classes with signals and slots are added to the HEADERS qmake variable. E.g.:</p>
<p><span style="color: #ff6600;">HEADERS +=</span> myheaderwithsignalsslots.h \<br />
otherheaderwithsignalsslots.h</p>
<p>Make sure these header files are in the include path. You can add your include directory to the INCLUDEPATH qmake variable. E.g.:</p>
<p><span style="color: #ff6600;">INCLUDEPATH +=</span> . ./include</p>
<p>Now try to compile again:</p>
<p>make clean<br />
manually remove all generated files especially which has suspicious &#8216;moc&#8217; in their names <img src='http://www.xistix.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  if make didn&#8217;t do that<br />
rm Makefile<br />
qmake<br />
make</p>
<p>If the problem still exist, check the <span style="color: #ff6600;">header file</span> itself which contains the class in question. Make sure that the class is actually defined in a header file and <span style="color: #ff6600;">not in a cpp</span>!</p>
<p>Every class which has signals and slots has to be <span style="color: #ff6600;">inherited from QObject</span> directly or indirectly.</p>
<p>Right after the opening curly bracket you should include the <span style="color: #ff6600;">Q_OBJECT</span> macro. E.g.:</p>
<p>class ArthurCanvas : public QWidget<br />
{<br />
Q_OBJECT<br />
&#8230;</p>
<p>If you have a class that is inherited from QObject but in this class you do not introduce new signals and/or slots you should not include the Q_OBJECT macro.</p>
<p>One more thing you can check if nothing helps. This will not solve the problem, but will help you to investigate. Check the <span style="color: #ff6600;">Makefile</span> that qmake generates:</p>
<p>rm Makefile<br />
qmake</p>
<p>Open Makefile in a text editor and look for</p>
<p><span style="color: #ff6600;">compiler_moc_header_make_all</span>:<br />
and<br />
<span style="color: #ff6600;">compiler_moc_header_clean</span>:<br />
and the entries after these</p>
<p>They should have references related to your header file in question. E.g. if you had foo.h you should have moc_foo.cpp listed for compiler_moc_header_make_all. If it is not the case, than qmake did not find the header file or the header file has some problem and qmake thinks it does not need to be moc-ed&#8230;</p>
<p>Finally, I do not recommend to mess up with including moc generated stuff manually to your makefile unless you know what you are doing. If your project file is correct, qmake will generate a correct Makefile to you.<br />
I hope these will help&#8230; Never forget your towel!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.xistix.com/blog/2008/12/12/qt-undefined-reference-to-vtable/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>A QT Project &#8211; Fractal Generator &#8211; About</title>
		<link>http://www.xistix.com/blog/2008/12/11/a-qt-project-fractal-generator-about/</link>
		<comments>http://www.xistix.com/blog/2008/12/11/a-qt-project-fractal-generator-about/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 13:58:11 +0000</pubDate>
		<dc:creator>Isti</dc:creator>
				<category><![CDATA[Arthur Fractal Generator]]></category>
		<category><![CDATA[QT Programming]]></category>
		<category><![CDATA[about]]></category>
		<category><![CDATA[dialog]]></category>
		<category><![CDATA[palette]]></category>

		<guid isPermaLink="false">http://www.kultatech.com/blog/?p=213</guid>
		<description><![CDATA[This post is just about some minor updates on Arthur. I added a default palette menu point to Arthur to make the original palette available any time. I also added an about dialog. I created the about dialog mainly with Designer. Then I just connected its execution to the corresponding menu point signal. Here are [...]]]></description>
			<content:encoded><![CDATA[<p>This post is just about some minor updates on Arthur. I added a default palette menu point to Arthur to make the original palette available any time. I also added an about dialog. I created the about dialog mainly with Designer. Then I just connected its execution to the corresponding menu point signal.</p>
<p>Here are the newest sources: <a href="http://www.kultatech.com/blog/wp-content/uploads/2008/12/fractal015.tgz">fractal015</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xistix.com/blog/2008/12/11/a-qt-project-fractal-generator-about/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A QT Project &#8211; Fractal Generator &#8211; Loading Palette</title>
		<link>http://www.xistix.com/blog/2008/12/10/a-qt-project-fractal-generator-loading-palette/</link>
		<comments>http://www.xistix.com/blog/2008/12/10/a-qt-project-fractal-generator-loading-palette/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 21:45:28 +0000</pubDate>
		<dc:creator>Isti</dc:creator>
				<category><![CDATA[Arthur Fractal Generator]]></category>
		<category><![CDATA[QT Programming]]></category>
		<category><![CDATA[Gimp]]></category>
		<category><![CDATA[palette]]></category>

		<guid isPermaLink="false">http://www.kultatech.com/blog/?p=209</guid>
		<description><![CDATA[So far I didn&#8217;t spend too much time with the colors themselves in the palette. I used a palette which I generated by changing the rgb values linearly. I still do not want to spend time for figuring out new palette generation algorithms or implementing existing ones. Rather I added palette loading functionality to Arthur [...]]]></description>
			<content:encoded><![CDATA[<p>So far I didn&#8217;t spend too much time with the colors themselves in the palette. I used a palette which I generated by changing the rgb values linearly. I still do not want to spend time for figuring out new palette generation algorithms or implementing existing ones. Rather I added palette loading functionality to Arthur to load ready made palettes. This way palettes can be generated by other programs like GIMP. So I checked what palette file format gimp is using. It is very simple. The rgb values are stored in a text file. Each value is in its own line. Values are separated by white spaces. I wrote a loader that opens a text file and reads lines from it until the end of the file or until we filled all the 256 colors in the color table.</p>
<p>For each line I do the followings:</p>
<ol>
<li>Simplify the line (white spaces converted to spaces)</li>
<li>Split the line to items at each space</li>
<li>Remove empty items</li>
<li>If we had at least three items remained, try to convert the first three items to integer numbers.</li>
<li>If all the three conversion went fine, add the color to the color table</li>
</ol>
<p>If the file ends before we fill all the 256 colors, the loader fills the rest of the colors with black values.</p>
<p>If the file contains more than 256 color entries than the loader does not read further after the 256th color is loaded.</p>
<p>This way I can handle e.g. GIMP palette files (*.gpl) or anything that fulfills the rule of the algorithm above.</p>
<p>I added a palette folder to the sources and copied two palettes from GIMP as examples.</p>
<p>Here is a Julia fractal rendered with the Firecode.gpl palette:</p>
<p><a href="http://www.xistix.com/blog/wp-content/uploads/2008/12/fire.png"><img class="alignnone size-medium wp-image-210" title="fire" src="http://www.kultatech.com/blog/wp-content/uploads/2008/12/fire-277x300.png" alt="" width="277" height="300" /></a></p>
<p>You can get the sources from here: <a href="http://www.kultatech.com/blog/wp-content/uploads/2008/12/fractal014.tgz">fractal014</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xistix.com/blog/2008/12/10/a-qt-project-fractal-generator-loading-palette/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A QT Project &#8211; Fractal Generator &#8211; Palette Rotation</title>
		<link>http://www.xistix.com/blog/2008/12/10/a-qt-project-fractal-generator-palette-rotation/</link>
		<comments>http://www.xistix.com/blog/2008/12/10/a-qt-project-fractal-generator-palette-rotation/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 12:36:09 +0000</pubDate>
		<dc:creator>Isti</dc:creator>
				<category><![CDATA[Arthur Fractal Generator]]></category>
		<category><![CDATA[QT Programming]]></category>
		<category><![CDATA[Gimp]]></category>
		<category><![CDATA[palette]]></category>
		<category><![CDATA[rotation]]></category>

		<guid isPermaLink="false">http://www.kultatech.com/blog/?p=201</guid>
		<description><![CDATA[Adding palette rotation to Arthur was fairly easy. All I had to do is to add some buttons to the UI for stepping and rotating back and forth and an additional stop button for stopping rotation. Then I connected the action handlers to the buttons. Since I handle the image as an indexed image, stepping [...]]]></description>
			<content:encoded><![CDATA[<p>Adding palette rotation to Arthur was fairly easy. All I had to do is to add some buttons to the UI for stepping and rotating back and forth and an additional stop button for stopping rotation. Then I connected the action handlers to the buttons. Since I handle the image as an indexed image, stepping the palette means stepping the colors in the palette. So I implemented a step forward method, which copies every color in the palette one position forward and copies the last color to the first place. I also made another method that does the same in the opposite direction. When I need step, I simply call the corresponding method. When I need continuous rotation I need to call these methods again and again. So I implemented the methods as slots. I introduced timers for the forward and backward rotation. And in the canvas constructor I connected the timer event signals to the corresponding palette step slots. The rotation activation means starting the corresponding timer. Stopping is just stopping the timer. Easy, isn&#8217;t it?</p>
<p>Here is a screenshot about Arthur with its new palette buttons:</p>
<p><a href="http://www.xistix.com/blog/wp-content/uploads/2008/12/palettebuttons.png"><img class="alignnone size-medium wp-image-207" title="palettebuttons" src="http://www.kultatech.com/blog/wp-content/uploads/2008/12/palettebuttons-280x300.png" alt="" width="280" height="300" /></a></p>
<p>Here is an animated GIF. I saved the frames as PNG images from Arthur. I made one forward palette step before saving the next frame. Then I used GIMP to make an animated GIF from the PNGs.</p>
<p><a href="http://www.xistix.com/blog/wp-content/uploads/2008/12/paletterotation.gif"><img class="alignnone size-full wp-image-204" title="paletterotation" src="http://www.xistix.com/blog/wp-content/uploads/2008/12/paletterotation.gif" alt="" width="320" height="240" /></a></p>
<p>You can get the sources from here: <a href="http://www.kultatech.com/blog/wp-content/uploads/2008/12/fractal013.tgz">fractal013</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xistix.com/blog/2008/12/10/a-qt-project-fractal-generator-palette-rotation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A QT Project &#8211; Fractal Generator &#8211; New Canvas</title>
		<link>http://www.xistix.com/blog/2008/12/10/a-qt-project-fractal-generator-new-canvas/</link>
		<comments>http://www.xistix.com/blog/2008/12/10/a-qt-project-fractal-generator-new-canvas/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 08:53:46 +0000</pubDate>
		<dc:creator>Isti</dc:creator>
				<category><![CDATA[Arthur Fractal Generator]]></category>
		<category><![CDATA[QT Programming]]></category>
		<category><![CDATA[Canvas]]></category>
		<category><![CDATA[selection]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://www.kultatech.com/blog/?p=194</guid>
		<description><![CDATA[In the former posts I experimented with a custom widget containing a QImage. I integrated that widget to Arthur. I replaced the old QLabel and QPixmap based widget with this custom widget. This way I have more freedom with image handling. I could even have direct access to image memory etc. The other benefit is [...]]]></description>
			<content:encoded><![CDATA[<p>In the former posts I experimented with a custom widget containing a QImage. I integrated that widget to Arthur. I replaced the old QLabel and QPixmap based widget with this custom widget. This way I have more freedom with image handling. I could even have direct access to image memory etc. The other benefit is that QImage can handle indexed images, so I do not need a separate map for holding color indexes and I can also avoid copying the map to pixmap.</p>
<p>I also changed the way of selection a bit. Now the point, where the mouse is pressed first will remain in the center of the selection. This way the user can center the most interesting part in the resulting picture.</p>
<p>Here is a screenshot:</p>
<p><a href="http://www.xistix.com/blog/wp-content/uploads/2008/12/mandelbrotnewcanvas.png"><img class="alignnone size-medium wp-image-195" title="mandelbrotnewcanvas" src="http://www.kultatech.com/blog/wp-content/uploads/2008/12/mandelbrotnewcanvas-281x300.png" alt="" width="281" height="300" /></a></p>
<p>There is no difference in appearance anyway <img src='http://www.xistix.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>You can get the sources from here: <a href="http://www.kultatech.com/blog/wp-content/uploads/2008/12/fractal012.tgz">fractal012</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xistix.com/blog/2008/12/10/a-qt-project-fractal-generator-new-canvas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Canvas Widget</title>
		<link>http://www.xistix.com/blog/2008/12/09/custom-canvas-widget/</link>
		<comments>http://www.xistix.com/blog/2008/12/09/custom-canvas-widget/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 11:55:43 +0000</pubDate>
		<dc:creator>Isti</dc:creator>
				<category><![CDATA[QT Programming]]></category>
		<category><![CDATA[Canvas]]></category>
		<category><![CDATA[indexed]]></category>
		<category><![CDATA[QImage]]></category>
		<category><![CDATA[size]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false">http://www.kultatech.com/blog/?p=191</guid>
		<description><![CDATA[I continued developing the custom canvas from the former post. I changed the image to be an indexed image. There are 256 colors. The moving dot is changing its color with every step. I also added the selection drawing. It actually does nothing just draws the selection. Now it is mature enough to integrate it [...]]]></description>
			<content:encoded><![CDATA[<p>I continued developing the custom canvas from the former post. I changed the image to be an indexed image. There are 256 colors. The moving dot is changing its color with every step. I also added the selection drawing. It actually does nothing just draws the selection. Now it is mature enough to integrate it to the Arthur fractal generator.</p>
<p>Sources are available here: <a href="http://www.kultatech.com/blog/wp-content/uploads/2008/12/qimage002.tgz">qimage002</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xistix.com/blog/2008/12/09/custom-canvas-widget/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drawing to a Canvas in QT</title>
		<link>http://www.xistix.com/blog/2008/12/09/drawing-to-a-canvas-in-qt/</link>
		<comments>http://www.xistix.com/blog/2008/12/09/drawing-to-a-canvas-in-qt/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 09:25:14 +0000</pubDate>
		<dc:creator>Isti</dc:creator>
				<category><![CDATA[QT Programming]]></category>
		<category><![CDATA[Canvas]]></category>
		<category><![CDATA[QImage]]></category>
		<category><![CDATA[QWidget]]></category>

		<guid isPermaLink="false">http://www.kultatech.com/blog/?p=186</guid>
		<description><![CDATA[I decided to rewrite the image handling in the Arthur fractal generator. So far I used a class derived from QLabel to show the generated images, but I faced some problems with this approach. QLabel is using QPixmap for showing an image. QPixmap is usually used for showing static images, but I want something more [...]]]></description>
			<content:encoded><![CDATA[<p>I decided to rewrite the image handling in the Arthur fractal generator. So far I used a class derived from QLabel to show the generated images, but I faced some problems with this approach. QLabel is using QPixmap for showing an image. QPixmap is usually used for showing static images, but I want something more dynamic. E.g. showing the changes on the image when a new pixel or row is calculated in the fractal. I also need indexed images. So I decided to write a new widget using QImage for the image representation. QImage can handle indexed images. It also has another advantage. While QPixmap is stored on the X-server, QImage is stored locally. Therefore I can have direct access to its memory space, which makes rendering much faster.</p>
<p>I started googleing around to find some simple examples for showing a QImage and drawing pixels on it with immediate feedback. No luck. Finally I ended up with the cannonfield tutorial coming with qt sources. It has a widget, and a bullet is drawn on the widget while it is moving. It does not use QImage, but good enough for seeing the widget basics, updates etc. So I started to modify it. I removed all unnecessary stuff. I added a QImage as a private attribute. In the paint event handler method I draw the QImage.</p>
<p>I decided to make a moving dot bouncing from the image borders as a demo. I kept the timer from the original example. I connected the timer event to a slot which handles the dot moving and rewriting.<br />
I also simplified the main.cpp. I have only this one widget to show. I got it working pretty fast and the results are convincing. Now, I go on to introduce the selection feature what I used in ArthurCanvas and I also try indexed image instead of the RGB image of the current example.</p>
<p>You can get the sources from here: <a href="http://www.kultatech.com/blog/wp-content/uploads/2008/12/qimage001.tgz">qimage001</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xistix.com/blog/2008/12/09/drawing-to-a-canvas-in-qt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A QT Project &#8211; Fractal Generator &#8211; Julia</title>
		<link>http://www.xistix.com/blog/2008/12/05/a-qt-project-fractal-generator-julia/</link>
		<comments>http://www.xistix.com/blog/2008/12/05/a-qt-project-fractal-generator-julia/#comments</comments>
		<pubDate>Fri, 05 Dec 2008 19:23:20 +0000</pubDate>
		<dc:creator>Isti</dc:creator>
				<category><![CDATA[Arthur Fractal Generator]]></category>
		<category><![CDATA[QT Programming]]></category>
		<category><![CDATA[dialog]]></category>
		<category><![CDATA[Julia]]></category>
		<category><![CDATA[mandelbrot]]></category>

		<guid isPermaLink="false">http://www.kultatech.com/blog/?p=181</guid>
		<description><![CDATA[I have added a new fractal formula to Arthur. Now it is possible to select from two fractals Mandelbrot and Julia. Julia is very similar to the Manderlbrot. The difference is that Julia uses a constant in the equation, which remains the same for the whole set at any point. The most interesting Julia fractals [...]]]></description>
			<content:encoded><![CDATA[<p>I have added a new fractal formula to Arthur. Now it is possible to select from two fractals Mandelbrot and <span style="color: #ff6600;">Julia</span>. Julia is very similar to the Manderlbrot. The difference is that <span style="color: #ff6600;">Julia uses a constant</span> in the equation, which remains the same for the whole set at any point. The most interesting Julia fractals can be generated with <span style="color: #ff6600;">constants</span> which are <span style="color: #ff6600;">close to the boundaries</span> of the corresponding <span style="color: #ff6600;">Mandelbrot</span> set. I added a <span style="color: #ff6600;">dialog</span> to the <span style="color: #ff6600;">calculator constructor</span> which reads the <span style="color: #ff6600;">Julia constant from text line inputs</span>. To ease the selection of good values I also added a <span style="color: #ff6600;">label with a Mandelbrot set picture</span>. The label is promoted to an inherited class which handles mouse press events. With the help of <span style="color: #ff6600;">signals and slots</span> I connected the event handler to the <span style="color: #ff6600;">setText</span> <span style="color: #ff6600;">slots</span> of the line edits. The user can click somewhere around the boundary and get the corresponding Julia constant to the line edits.</p>
<p>Here is screenshot of the dialog:</p>
<p><a href="http://www.xistix.com/blog/wp-content/uploads/2008/12/juliaconstantdialog.png"><img class="alignnone size-medium wp-image-182" title="Julia Constant Dialog" src="http://www.kultatech.com/blog/wp-content/uploads/2008/12/juliaconstantdialog-265x300.png" alt="" width="265" height="300" /></a></p>
<p>Here is a Julia fractal generated by Arthur:</p>
<p><a href="http://www.xistix.com/blog/wp-content/uploads/2008/12/julia.jpg"><img class="alignnone size-medium wp-image-183" title="Julia" src="http://www.kultatech.com/blog/wp-content/uploads/2008/12/julia-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>You can get the sources from here: <a href="http://www.kultatech.com/blog/wp-content/uploads/2008/12/fractal011.tgz">fractal011</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.xistix.com/blog/2008/12/05/a-qt-project-fractal-generator-julia/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

