<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.1.2" -->
<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/"
	>

<channel>
	<title>Trolltech Labs Blogs</title>
	<link>http://labs.trolltech.com/blogs</link>
	<description>the ramblings of engineers</description>
	<pubDate>Wed, 23 Jul 2008 14:11:46 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1.2</generator>
	<language>en</language>
			<item>
		<title>A sturdier bridge (still troubled water underneath)</title>
		<link>http://labs.trolltech.com/blogs/2008/07/23/a-sturdier-bridge-still-troubled-water-underneath/</link>
		<comments>http://labs.trolltech.com/blogs/2008/07/23/a-sturdier-bridge-still-troubled-water-underneath/#comments</comments>
		<pubDate>Wed, 23 Jul 2008 14:11:46 +0000</pubDate>
		<dc:creator>eskil</dc:creator>
		
		<category><![CDATA[Qt Jambi]]></category>

		<guid isPermaLink="false">http://labs.trolltech.com/blogs/2008/07/23/a-sturdier-bridge-still-troubled-water-underneath/</guid>
		<description><![CDATA[A while back we announced the research project Qt Jambi AWT Bridge which allows you to mix AWT/Swing components and Qt widgets in the same window on Windows and Linux. 
There were a few issues with the original version. The main problems were the fact that your window would be deactivated by the window manager [...]]]></description>
			<content:encoded><![CDATA[<p>A while back we <a href="http://labs.trolltech.com/blogs/2007/10/18/a-bridge-over-troubled-water/">announced</a> the research project <a href="http://labs.trolltech.com/page/Projects/QtJambi/QtJambiAwtBridge">Qt Jambi AWT Bridge</a> which allows you to mix AWT/Swing components and Qt widgets in the same window on Windows and Linux. </p>
<p>There were a few issues with the original version. The main problems were the fact that your window would be deactivated by the window manager when you clicked inside an embedded widget, some issues with unnecessary whitespace around the embedded components when you embedded AWT inside of Qt, and some people experienced a race condition which caused the embedded widgets to sometimes disappear. </p>
<p>The project has now largely been rewritten to be more robust, and both the window activation issues and whitespace issues have been resolved. If you sync the latest version from Subversion, you should be able to see major improvements. There are still some issues with keyboard focus (tabbing between the application widgets and the embedded widgets) which we are trying to resolve. </p>
<p>The sequence of commands to build has also changed. Please follow the following steps in order to build the project from source (for users of a binary package of Qt Jambi, we will try to get binaries for the bridge up at some point.) The following steps will only work if you have also built Qt Jambi from source.</p>
<p>Windows (Replace &#8220;nmake&#8221; with the &#8220;make&#8221;-application of your choice.)<br />
<code>set JAMBIDIR=\path\to\jambi\source\package<br />
set JAVADIR=\path\to\java\sdk<br />
.\generatorstep.bat<br />
qmake<br />
nmake</code></p>
<p>Linux<br />
<code>export JAMBIDIR=/path/to/jambi/source/package<br />
export JAVADIR=/path/java/sdk<br />
./generatorstep.sh<br />
qmake<br />
make</code></p>
<p>That should take care of building the native binaries. Then put Qt Jambi in your class path and compile all the .java files:</p>
<p><code>javac com/trolltech/research/qtjambiawtbridge/generated/*.java<br />
javac com/trolltech/research/qtjambiawtbridge/*.java<br />
javac com/trolltech/research/qtjambiawtbridge/examples/*.java</code></p>
<p>There are two examples in the com.trolltech.research.qtjambiawtbridge.examples package: QtInAwt and AwtInQt. These are the same as before, and show, respectively, how to integrate a Qt widget in an AWT frame, and how to integrate an AWT component in a Qt widget. Here&#8217;s a screen shot of QtInAwt:</p>
<p><a href='http://labs.trolltech.com/blogs/wp-content/uploads/2008/07/awtbridgescreenshot.png' title='awtbridgescreenshot.png'><img src='http://labs.trolltech.com/blogs/wp-content/uploads/2008/07/awtbridgescreenshot.png' alt='awtbridgescreenshot.png' /></a></p>
<p>The window here is handled by AWT, the two input fields and labels for the name are Swing components, and the entire bottom part is a layout created in Qt Jambi. </p>
<p>Please go to the <a href="http://labs.trolltech.com/page/Projects/QtJambi/QtJambiAwtBridge">project homepage</a> for more information.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.trolltech.com/blogs/2008/07/23/a-sturdier-bridge-still-troubled-water-underneath/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Underwater effect</title>
		<link>http://labs.trolltech.com/blogs/2008/07/13/underwater-effect/</link>
		<comments>http://labs.trolltech.com/blogs/2008/07/13/underwater-effect/#comments</comments>
		<pubDate>Sun, 13 Jul 2008 14:27:54 +0000</pubDate>
		<dc:creator>ariya</dc:creator>
		
		<category><![CDATA[Qt]]></category>

		<category><![CDATA[Graphics Dojo]]></category>

		<guid isPermaLink="false">http://labs.trolltech.com/blogs/2008/07/13/underwater-effect/</guid>
		<description><![CDATA[Distorting the geometry of an image with a specific periodic pattern can give the illusion of being underwater. This trick was for example employed in the very first version of Quake, either to oscillate the water surface or to modify the view when you jump inside the water. Apparently, it is not difficult to do [...]]]></description>
			<content:encoded><![CDATA[<p>Distorting the geometry of an image with a specific periodic pattern can give the illusion of being underwater. This trick was for example employed in the very first version of Quake, either to oscillate the water surface or to modify the view when you jump inside the water. Apparently, it is not difficult to do that, even with pixel-per-pixel manipulation of QImage.</p>
<p>Check out the code from the usual place:</p>
<pre>svn checkout svn://labs.trolltech.com/svn/graphics/dojo/underwater</pre>
<p>It is recommended to build the program and see the effect by yourself, the following screenshot can hardly describe the animation. As usual, once the example is running (it would show the included bridge picture), you can change the picture by dragging an image (from local disk or a web browser, e.g. Flickr or Picasa Web) and dropping it on the main window.</p>
<p><a href="http://www.flickr.com/photos/ariyahidayat/2664092556/sizes/o/" title="Qt for doing underwater effect by Ariya Hidayat, on Flickr"><img src="http://farm4.static.flickr.com/3261/2664092556_4c34b872cc.jpg" alt="Qt for doing underwater effect" border="0" /></a></p>
<p>Note: the snappers picture is from <a href="http://www.flickr.com/photos/68567841@N00/168870580/">james_wicks</a>, distributed under the <a href="http://creativecommons.org/licenses/by/2.0/deed.en">Creative Commons Attribution 2.0 Generic</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.trolltech.com/blogs/2008/07/13/underwater-effect/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Usage of the QFormLayout</title>
		<link>http://labs.trolltech.com/blogs/2008/07/07/usage-of-the-qformlayout/</link>
		<comments>http://labs.trolltech.com/blogs/2008/07/07/usage-of-the-qformlayout/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 09:01:51 +0000</pubDate>
		<dc:creator>Friedemann Kleint</dc:creator>
		
		<category><![CDATA[Qt]]></category>

		<guid isPermaLink="false">http://labs.trolltech.com/blogs/2008/07/07/usage-of-the-qformlayout/</guid>
		<description><![CDATA[Hi there. Introducing myself, my name is Friedemann Kleint, and I am one of the trolls hacking away at Qt Designer at the Berlin Office.
Today, I would like to draw your attention to the QFormLayout class. This is a special layout class suited to the common descriptive label - control arrangement found in  many [...]]]></description>
			<content:encoded><![CDATA[<p>Hi there. Introducing myself, my name is Friedemann Kleint, and I am one of the trolls hacking away at Qt Designer at the Berlin Office.</p>
<p>Today, I would like to draw your attention to the QFormLayout class. This is a special layout class suited to the common descriptive label - control arrangement found in  many dialogs. It thas been developed in cooperation between Brisbane, Oslo and Berlin. </p>
<p>A typical form layout looks like this:</p>
<p><a href='http://labs.trolltech.com/blogs/wp-content/uploads/2008/07/form1_1.png' title='QFormLayout example 1'><img src='http://labs.trolltech.com/blogs/wp-content/uploads/2008/07/form1_1.png' alt='QFormLayout example 1' /></a></p>
<p><a href='http://labs.trolltech.com/blogs/wp-content/uploads/2008/07/form1_2.png' title='QFormLayout example 2'><img src='http://labs.trolltech.com/blogs/wp-content/uploads/2008/07/form1_2.png' alt='QFormLayout example 2' /></a></p>
<p>Note how the layout takes care of the label alignment according to the platform style. By the way, did you know that you can open several previews in different styles in Designer to compare them?</p>
<p>At first sight, QFormLayout looks like an ordinary grid. However, the layout also has policies for wrapping rows when it shrinks. For example, when setting the property <code>rowWrapPolicy</code> to <code>WrapLongRows</code>, we might get:</p>
<p><a href='http://labs.trolltech.com/blogs/wp-content/uploads/2008/07/formwrapping.png' title='QFormLayout’s wrapping policy in effect'><img src='http://labs.trolltech.com/blogs/wp-content/uploads/2008/07/formwrapping.png' alt='QFormLayout’s wrapping policy in effect' /></a></p>
<p>Let&#8217;s first have a look at the code. You might have created a such dialogs using QGridLayout, previously. This required some housekeeping of the current row. This is no longer necessary with QFormLayout using the <code>addRow()</code> convencience function. You don&#8217;t have to explicitly create the label, either:</p>
<p><code>QFormLayout *formLayout = new QFormLayout;<br />
formLayout-&gt;addRow("Name", new QLineEdit);</code></p>
<p>For completeness, there is a <code>setWidget()</code> function which allows you to address single cells. It takes a row parameter and an ItemRole enumeration, which can be one of <code>QFormLayout::LabelRole</code> or <code>QFormLayout::FieldRole</code>.</p>
<p>In Qt Designer, you can create such arrangements as would in the case of a QGridLayout; you place the controls on a form and choose <em>&#8220;Lay Out in a Form Layout&#8221;</em>.</p>
<p>Hint: If you have existing .ui files containing such 2-column grid layouts and want to migrate them to the form layout, it might be sufficient to just replace the layout element   <code>&lt;layout class="QGridLayout" name="gridLayout" &gt;&lt;/layout&gt;</code> by something like   <code>&lt;layout class="QFormLayout" name="formLayout" &gt;&lt;/layout&gt;</code>   (after making a backup copy, of course <img src='http://labs.trolltech.com/blogs/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> ).</p>
<p>It is also possible to create arrangements with controls that span the 2 columns. This let&#8217;s you add controls with long labels (for example QComboBox) or QGroupBox elements. It can also be used to partition the form layout into sections by using spanning QLabel elements:</p>
<p><a href='http://labs.trolltech.com/blogs/wp-content/uploads/2008/07/formspanning.png' title='A form layout arrangement with spanning labels'><img src='http://labs.trolltech.com/blogs/wp-content/uploads/2008/07/formspanning.png' alt='A form layout arrangement with spanning labels' /></a></p>
<p>In code, you would use the <code>addRow()</code> overload that takes just one  QWidget* parameter.</p>
<p>In the upcoming 4.5 release, this functionality will also be available in Designer. Lonesone widgets on a QFormLayout get an active left/right resize handle that let&#8217;s you change the span:</p>
<p><a href='http://labs.trolltech.com/blogs/wp-content/uploads/2008/07/formspanninghandle.png' title='Changing the span of a QFormLayout element in Designer'><img src='http://labs.trolltech.com/blogs/wp-content/uploads/2008/07/formspanninghandle.png' alt='Changing the span of a QFormLayout element in Designer' /></a></p>
<p>The per-cell API of the QFormLayout uses the <code>SpanningRole</code> enumeration value of <code>ItemRole </code> to handle these rows.</p>
<p>Summarizing, the QFormLayout should be used whereever the typical descriptive label - control arrangement occurs. The dialog will then look correctly on a all  platforms.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.trolltech.com/blogs/2008/07/07/usage-of-the-qformlayout/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Let there be color</title>
		<link>http://labs.trolltech.com/blogs/2008/07/05/let-there-be-color/</link>
		<comments>http://labs.trolltech.com/blogs/2008/07/05/let-there-be-color/#comments</comments>
		<pubDate>Sat, 05 Jul 2008 19:48:18 +0000</pubDate>
		<dc:creator>ariya</dc:creator>
		
		<category><![CDATA[Qt]]></category>

		<category><![CDATA[Graphics Dojo]]></category>

		<guid isPermaLink="false">http://labs.trolltech.com/blogs/2008/07/05/let-there-be-color/</guid>
		<description><![CDATA[Time for another fresh example for the Graphics Dojo. This time I present a small tool that does nothing but showing the famous HSV cylinder. To give some realism, subtle blurred reflection is also added but can be easily disabled. Manual full-scene anti-aliasing is provided by the usual multisampling approach. Everything is done using pure [...]]]></description>
			<content:encoded><![CDATA[<p>Time for another fresh example for the <a href="http://labs.trolltech.com/page/Graphics/About/Dojo">Graphics Dojo</a>. This time I present a small tool that does nothing but showing the famous <a href="http://en.wikipedia.org/wiki/Image:HSV_cylinder.png">HSV cylinder</a>. To give some realism, subtle blurred reflection is also added but can be easily disabled. Manual full-scene anti-aliasing is provided by the usual multisampling approach. Everything is done using pure QImage per-pixel manipulation along with some tricks, no OpenGL (or even its GLSL) is involved.</p>
<p><a href="http://flickr.com/photos/ariyahidayat/2634601175/sizes/o/" title="HSV Pie by Ariya Hidayat, on Flickr"><img src="http://farm4.static.flickr.com/3046/2634601175_bf1a3d4ab1.jpg" alt="HSV Pie" border="0" /></a></p>
<p>For the code, check it out using:</p>
<pre>svn checkout svn://labs.trolltech.com/svn/graphics/dojo/hsvpie</pre>
<p>Note that the tool is not optimized for speed (evidenced by lots of setPixel() calls) so there is definitely room for improvement. Some possible further enhancements left as exercises for the readers are interactivity (mouse dragging to change e.g. the depth of the pie) and threaded rendering (so that the application remains responsive, just adapt the <a href="http://doc.trolltech.com/4.4/threads-mandelbrot.html">Mandelbrot example</a>).</p>
<p>Have some dojo-fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.trolltech.com/blogs/2008/07/05/let-there-be-color/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Putting QtWebKit to use with Google Maps</title>
		<link>http://labs.trolltech.com/blogs/2008/07/03/putting-qtwebkit-to-use-with-google-maps/</link>
		<comments>http://labs.trolltech.com/blogs/2008/07/03/putting-qtwebkit-to-use-with-google-maps/#comments</comments>
		<pubDate>Thu, 03 Jul 2008 11:03:27 +0000</pubDate>
		<dc:creator>Henrik Hartz</dc:creator>
		
		<category><![CDATA[Qt]]></category>

		<category><![CDATA[WebKit]]></category>

		<category><![CDATA[Itemviews]]></category>

		<guid isPermaLink="false">http://labs.trolltech.com/blogs/2008/07/03/putting-qtwebkit-to-use-with-google-maps/</guid>
		<description><![CDATA[Hi there. This is my first blog post, so I guess introductions are in order; My name is Henrik Hartz, and work as a Specialist with Product Management in Troll^W Qt Software. In Product Management I do all kinds of stuff, ranging from working with requirements, specifications, product releases, meeting customers, thinking about the future [...]]]></description>
			<content:encoded><![CDATA[<p>Hi there. This is my first blog post, so I guess introductions are in order; My name is Henrik Hartz, and work as a Specialist with Product Management in Troll^W Qt Software. In Product Management I do all kinds of stuff, ranging from working with requirements, specifications, product releases, meeting customers, thinking about the future of Qt, the list goes on.. Recently I&#8217;ve had the pleasure of focusing on WebKit.</p>
<p>WebKit is a fantastic technology. Being able to stick web content into your application is simply amazing, there&#8217;s just about anything out there you can show! And, a lot of people know HTML, so making use of this to add content to your application enables you to (ab)use your Graphic Designer buddies.</p>
<p>But, WebKit is so much more than just a way to show HTML in your app. You can actually do anything a browser can - and much more! Experimenting with WebKit over the last couple of months I&#8217;ve made an example that a lot of people seem to be interested in; Using WebKit to host a Google Maps component.</p>
<p>I wanted to show where our offices are located in the world. So, I started with a simple QStandardItemModel that would read in addresses from a txt file. In the constructor, we read in the text file - using the first field of the comma separated line as the display role, and the rest as the address stored in the UserRole;</p>
<blockquote><p>
<code style="white-space: pre">QStringList addressLines = address.split(",");</code><br />
<br />
<code style="white-space: pre">QStandardItem *item = new QStandardItem;</code><br />
<code style="white-space: pre">this-&gt;insertRow(this-&gt;rowCount(),item);</code><br />
<br />
<code style="white-space: pre">item-&gt;setData(addressLines.takeFirst(), Qt::DisplayRole);</code><br />
<code style="white-space: pre">item-&gt;setData(addressLines.join(",").trimmed(),Qt::UserRole);</code>
</p></blockquote>
<p>With this model in place, we simply set it on the list view of our GUI design (yeah, I like using Qt Designer - it&#8217;s fast!);</p>
<blockquote><p>
<code style="white-space: pre">ui.treeView-&gt;setModel(new AddressModel(this));</code>
</p></blockquote>
<p>In the GUI we&#8217;ve also placed a web view, which is pointed to a web page under our control. This page shows a <a href="http://code.google.com/apis/maps/" target="new">Google Maps</a> control. So here is the GUI with the address list and QtWebKit component;</p>
<p><img src="http://labs.trolltech.com/blogs/wp-content/uploads/2008/07/mainwindow.png" title="GUI design" alt="GUI design" height="479" width="708" /></p>
<p>This doesn&#8217;t do much on it&#8217;s own - so we promote the QWebView class to a custom component &#8220;Map&#8221;, defined by map.h in Qt Designer. This component has some additional services that allow us to update the map, specifically;</p>
<blockquote><p>
<code style="white-space: pre">void geoCode(const QString &amp;address);</code>
</p></blockquote>
<p>What we want is to update the map based on the entries in the list view when they are clicked. We do this in a slot method connected to the clicked signal of my view. Here we can access the data of the item being clicked, extract the address and ask the map component to geo-code it;</p>
<blockquote><p>
<code style="white-space: pre">void MainWindow::showItem(const QModelIndex &amp;idx)</code><br />
<code style="white-space: pre">{</code><br />
<code style="white-space: pre">   ui.map-&gt;geoCode( idx.data( Qt::UserRole).toString() );</code><br />
<code style="white-space: pre">}</code>
</p></blockquote>
<p>The geoCode method will use QtWebKit&#8217;s capability of calling JavaScript functions in the web environment. Here we&#8217;ll use the Google Maps API to get Google to return a coordinate of the specified address in CSV format, using the asynchronous <code style="white-space: pre">QNetworkAccessManager::get(const QNetworkRequest &amp;amp;request)</code> API;</p>
<blockquote><p>
<code style="white-space: pre">void Map::geoCode(const QString &amp;address)</code><br />
<code style="white-space: pre">{</code><br />
<code style="white-space: pre">   QString requestStr( tr("http://maps.google.com/maps/geo?q=%1&amp;amp;output=%2&amp;amp;key=%3")</code><br />
<code style="white-space: pre">      .arg(address)</code><br />
<code style="white-space: pre">      .arg("csv")</code><br />
<code style="white-space: pre">      .arg("GOOGLE_MAPS_KEY") );</code><br />
<code style="white-space: pre"> </code><br />
<code style="white-space: pre">   manager-&gt;get( QNetworkRequest(requestStr) );</code><br />
<code style="white-space: pre">}</code>
</p></blockquote>
<p>In another method connected to the <code style="white-space: pre">QNetworkManager::finished(QNetworkReply*)</code> signal, we parse out the coordinate returned in CSV format from Google, and pass it to a method which updates the map component appropriately;</p>
<blockquote><p>
<code style="white-space: pre">void Map::loadCoordinates()</code><br />
<code style="white-space: pre">{</code><br />
<code style="white-space: pre">   QStringList scriptStr;</code><br />
<code style="white-space: pre">   scriptStr</code><br />
<code style="white-space: pre">      &lt; &lt; "var map = new GMap2(document.getElementById(\"map\"));"</code><br />
</code><code style="white-space: pre">      &lt; &lt; "var bounds = new GLatLngBounds;"</code><br />
</code><code style="white-space: pre">      &lt; &lt; "var markers = [];"</code><br />
</code><code style="white-space: pre">      &lt; &lt; "map.setCenter( new GLatLng(0,0),1 );";</code><br />
</code><code style="white-space: pre"> </code><br />
<code style="white-space: pre">   int num=-1;</code><br />
<code style="white-space: pre">   foreach( QPointF point, coordinates ) {</code><br />
<code style="white-space: pre">      scriptStr &lt; &lt; QString("markers[%1] = new GMarker(new GLatLng(%2, %3));")</code><br />
</code><code style="white-space: pre">         .arg(++num)</code><br />
<code style="white-space: pre">         .arg(point.x())</code><br />
<code style="white-space: pre">         .arg(point.y());</code><br />
<code style="white-space: pre">   }</code><br />
<code style="white-space: pre"> </code><br />
<code style="white-space: pre">   scriptStr</code><br />
<code style="white-space: pre">      &lt; &lt; "for( var i=0; i&lt;markers.length; ++i ) {"</code><br />
</code><code style="white-space: pre">      &lt; &lt; "   bounds.extend(markers[i].getPoint());"</code><br />
</code><code style="white-space: pre">      &lt; &lt; "   map.addOverlay(markers[i]);"</code><br />
</code><code style="white-space: pre">      &lt; &lt;    "}"</code><br />
</code><code style="white-space: pre">      &lt; &lt;    "map.setCenter(bounds.getCenter());";</code><br />
</code><code style="white-space: pre"> </code><br />
<code style="white-space: pre">      this-&gt;page()-&gt;mainFrame()-&gt;evaluateJavaScript( scriptStr.join("\n") );</code><br />
<code style="white-space: pre">}</code>
</p></blockquote>
<p>In the final call, we tell QtWebKit to evaluate the JavaScript we have synthesized, and the web view updates with the appropriate location;</p>
<p><img src="http://labs.trolltech.com/blogs/wp-content/uploads/2008/07/mainwindow2.png" title="Qt Software Address book" alt="Qt Software Address book" height="436" width="654" /></p>
<p>The snippets shown here are simplified to some extent, but you can find the complete source code <a href="http://chaos.troll.no/~hhartz/addressbook.tar" title="Qt Software Addressbook source .tar archive">here</a>. Please remember to put the HTML for the map component on a server you control - and replace the GOOGLE_MAPS_KEY with your own key (you need to register and bind to a domain for it to work) in both map.cpp and index.html.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.trolltech.com/blogs/2008/07/03/putting-qtwebkit-to-use-with-google-maps/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Some QTabBar &#038; QTabWidget love</title>
		<link>http://labs.trolltech.com/blogs/2008/07/02/some-qtabbar-qtabwidget-love/</link>
		<comments>http://labs.trolltech.com/blogs/2008/07/02/some-qtabbar-qtabwidget-love/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 14:56:34 +0000</pubDate>
		<dc:creator>Benjamin Meyer</dc:creator>
		
		<category><![CDATA[Qt]]></category>

		<guid isPermaLink="false">http://labs.trolltech.com/blogs/2008/07/02/some-qtabbar-qtabwidget-love/</guid>
		<description><![CDATA[After 4.4.0 was out I set aside some time to go though the feature requests for QTabBar &#038; QTabWidget.  After making a list of the most voted for suggestions I have implemented some features that will be in 4.5.0 that should make some developers happy.
In the past ten years the tab widget has gone [...]]]></description>
			<content:encoded><![CDATA[<p>After 4.4.0 was out I set aside some time to go though the feature requests for QTabBar &#038; QTabWidget.  After making a list of the most voted for suggestions I have implemented some features that will be in 4.5.0 that should make some developers happy.</p>
<p>In the past ten years the tab widget has gone from being something you see in a settings dialog to the widget that is the central widget of QMainWindow for many applications.  Trying to use QTabWidget in the main window as it is in 4.4.0 has a number of shortcomings.  One big issue is that if you maximize your application and move your mouse to the far right and try to scroll it wont because the mouse is actually over the 2px frame and not the scrollbar.  I present for your enjoyment <a href="http://doc.trolltech.com/main-snapshot/">QTabWidget::documentMode</a> which will only put the frame on the top with the tabs.  Another very annoying problem for QTabWidget was that if you wanted to add a context menu or handle any event in the tab bar area you had to subclass both QTabBar and QTabWidget because the empty area was actually owned by QTabWidget and the tab bar widget was only as big as the tabs. Document mode will cause the tab bar widget to take up the entire space above the tab widget which will simplify a lot of code.</p>
<p>Looking around at what features people have implemented in their subclasses of QTabBar many have added some sort of hack to be able to either put a widget on a tab or the ability to paint a button.  Doing this right, QTabBar now has a function <a href="http://doc.trolltech.com/main-snapshot/qtabbar.html#setTabButton">QTabBar::setTabButton</a> to let you put a widget on the left or right hand side of each tab.  Taking this one step further there is also a convenience property<br />
<a href="http://doc.trolltech.com/main-snapshot/qtabbar.html#tabsClosable-prop">QTabBar::tabsClosable</a> that when enabled will automatically add a close button to each tab.  The close button it painted by the style using PE_IndicatorTabClose.  When the close button is pressed the signal <a href="http://doc.trolltech.com/main-snapshot/qtabbar.html#tabCloseRequested">tabCloseRequested</a> is emitted.  Note that the location of the close button is also determined by the style so you can not guarantee that it will always be on the right hand side and the side with the close button should be determined by a call to the style with SH_TabBar_CloseButtonPosition.  Custom styles that paint tabs themselves needs to be updated to take into account the space needed for  buttons (see <a href="http://doc.trolltech.com/main-snapshot/qstyleoptiontabv3.html">QStyleOptionTabV3</a>).</p>
<p>When a tab is closed rather then always selecting the tab to the right there is now a<br />
<a href="http://doc.trolltech.com/main-snapshot/qtabbar.html#selectionBehaviorOnRemove-prop">QTabBar::selectionBehaviorOnRemove</a> property to decide which tab should be selected.  The three included values are left, right and the last selected tab.</p>
<p>Another highly requested feature is support for the ability to move tabs.  There is even a number of patches floating around out there that add many different moving schemes.  A <a href="http://doc.trolltech.com/main-snapshot/qtabbar.html#moveTab">moveTab</a> function was added, but taking it to the next level the property <a href="http://doc.trolltech.com/main-snapshot/qtabbar.html#movable-prop">movable</a> has been added which lets you drag the tabs around and as you pass over tabs they slide to their new position (i.e. animated sexiness).</p>
<p>Because animations are hard to describe I made a short video.  In the video I first add a QTabWidget to a QMainWindow, turn on document mode, closeable tabs, and the moveable property.  Then I preview it in plastique and drag around a few tabs.  I start out using cleanlooks so it picks up the Gtk close button and then in plastique you can see it using the default button.</p>
<object width="425" height="350">
<param name="movie" value="http://www.youtube.com/v/Bf-2GMpe_T0"> </param>
<p> <embed src="http://www.youtube.com/v/Bf-2GMpe_T0&#038;fmt=18" type="application/x-shockwave-flash" width="425" height="350"> </embed> </object>
<p>Lastly for applications running in OS X when using document mode the style paints the entire tab bar to match those tabbed applications like Safari and Terminal that are found on OS X.  Below is a screenshots of a QTabWidget in a QMainWindow with a QWebView.  With OS X it is very clear that the tab widget now goes to the edge of the screen.  </p>
<p><img src='http://labs.trolltech.com/blogs/wp-content/uploads/2008/07/picture-1.png' alt='osxstyletabbar.png' /></p>
<p>Hope you all enjoy it.  Some of the patches are already in Qt main, but you can find all of these in tonight&#8217;s snapshots.  Let me know if you notice any issues with the new features.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.trolltech.com/blogs/2008/07/02/some-qtabbar-qtabwidget-love/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Bloom effect</title>
		<link>http://labs.trolltech.com/blogs/2008/06/29/bloom-effect/</link>
		<comments>http://labs.trolltech.com/blogs/2008/06/29/bloom-effect/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 01:35:48 +0000</pubDate>
		<dc:creator>ariya</dc:creator>
		
		<category><![CDATA[Qt]]></category>

		<category><![CDATA[Graphics Dojo]]></category>

		<guid isPermaLink="false">http://labs.trolltech.com/blogs/2008/06/29/bloom-effect/</guid>
		<description><![CDATA[If you play games like Rainbox Six: Vegas or watch movies like Elephant Dream, you will notice the use of the so-called Bloom effect. In fact, Vegas is so bright and surrealist that this game becomes known for its Bloom overuse.
In this Graphics Dojo example, I would like to show how to render an image [...]]]></description>
			<content:encoded><![CDATA[<p>If you play games like <a href="http://rainbowsixgame.us.ubi.com/vegas/">Rainbox Six: Vegas</a> or watch movies like <a href="http://orange.blender.org/">Elephant Dream</a>, you will notice the use of the so-called <a href="http://en.wikipedia.org/wiki/Bloom_(shader_effect)">Bloom effect</a>. In fact, <em>Vegas</em> is so bright and surrealist that this game becomes known for its Bloom overuse.</p>
<p>In this Graphics Dojo example, I would like to show how to render an image with the Bloom effect. This extends the previous example from Zack on making  <a href="http://labs.trolltech.com/page/Graphics/Examples/Examples2">real-time glow effect</a>. The technique: create a copy of the image, blur it, increase its brightness and then combine with the original image with a certain composition mode and opacity. Since a picture is worth a 2^10 words, I will let the following screenshot (click to enlarge) speaks for itself.</p>
<p><a href="http://www.flickr.com/photos/ariyahidayat/2618305854/sizes/o/" title="Bloom effect with Qt by Ariya Hidayat, on Flickr"><img src="http://farm4.static.flickr.com/3011/2618305854_dff90e3731.jpg" title="Bloom effect with Qt" alt="Bloom effect with Qt" border="0" /></a></p>
<p>The image on the left side is the original, whereas the right one shows the result of applying Bloom. As you can see, there are few sliders where you can tweak the parameter to achieve the effect that suits your taste. Different composition modes can give (not so radically) different results as well, just play around with it.</p>
<p>How to get it? Just do &#8220;svn checkout svn://labs.trolltech.com/svn/graphics/dojo/bloom&#8221; followed by the usual &#8220;cd bloom &amp;&amp; qmake &amp;&amp; make &amp;&amp; ./bloom&#8221;. Once the main window shows up, you can also change the image by using drag-and-drop from a file on your disk or even a link from the web browser (e.g. straight from your Flickr gallery).  Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.trolltech.com/blogs/2008/06/29/bloom-effect/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Accelerate your widgets with OpenGL</title>
		<link>http://labs.trolltech.com/blogs/2008/06/27/accelerate-your-widgets-with-opengl/</link>
		<comments>http://labs.trolltech.com/blogs/2008/06/27/accelerate-your-widgets-with-opengl/#comments</comments>
		<pubDate>Fri, 27 Jun 2008 13:47:10 +0000</pubDate>
		<dc:creator>sroedal</dc:creator>
		
		<category><![CDATA[Qt]]></category>

		<category><![CDATA[Graphics View]]></category>

		<category><![CDATA[Graphics Items]]></category>

		<category><![CDATA[Graphics Dojo]]></category>

		<guid isPermaLink="false">http://labs.trolltech.com/blogs/2008/06/27/accelerate-your-widgets-with-opengl/</guid>
		<description><![CDATA[To breathe some new life into the graphics dojo, here&#8217;s an example of how to put widgets on top of an OpenGL scene using QGraphicsView. By leveraging the synergy (tounge in cheek) of the OpenGL module and graphics view&#8217;s in 4.4 new widget capabilities, the long lacking feature of putting widgets in OpenGL becomes possible. [...]]]></description>
			<content:encoded><![CDATA[<p>To breathe some new life into the graphics dojo, here&#8217;s an example of how to put widgets on top of an OpenGL scene using QGraphicsView. By leveraging the synergy (tounge in cheek) of the OpenGL module and graphics view&#8217;s in 4.4 new widget capabilities, the long lacking feature of putting widgets in OpenGL becomes possible. All that&#8217;s needed is to set a QGLWidget as viewport on the graphics view, override QGraphicsScene::drawBackground() to do the OpenGL rendering, and add widgets and other graphics items to the graphics scene as usual. The result can be seen in the screenshot below, which shows a simple obj-model viewer application written in just a couple of hundred lines of code:</p>
<p><a href="http://labs.trolltech.com/blogs/wp-content/uploads/2008/06/openglwidgets2.png" title="Widgets on top of an OpenGL scene"><img src="http://labs.trolltech.com/blogs/wp-content/uploads/2008/06/openglwidgets2.png" alt="Widgets on top of an OpenGL scene" /></a></p>
<p>The source code is available by &#8220;svn checkout svn://labs.trolltech.com/svn/graphics/dojo/modelviewer&#8221;. Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.trolltech.com/blogs/2008/06/27/accelerate-your-widgets-with-opengl/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Wide Finding</title>
		<link>http://labs.trolltech.com/blogs/2008/06/27/wide-finding/</link>
		<comments>http://labs.trolltech.com/blogs/2008/06/27/wide-finding/#comments</comments>
		<pubDate>Fri, 27 Jun 2008 12:24:41 +0000</pubDate>
		<dc:creator>Morten</dc:creator>
		
		<category><![CDATA[Threads]]></category>

		<category><![CDATA[Qt Concurrent]]></category>

		<guid isPermaLink="false">http://labs.trolltech.com/blogs/2008/06/27/wide-finding/</guid>
		<description><![CDATA[The Wide Finder Project is an informal parallel programming competition where the task is to compute web site statistcs from a 218-million line access log. Each entry will be benchmarked on a Sun T2000 with support for 32 hardware threads, giving lots of opportunities for parallel processing.
What makes this really interesting is that the project [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.tbray.org/ongoing/When/200x/2008/05/01/Wide-Finder-2">Wide Finder Project</a> is an informal parallel programming competition where the task is to compute web site statistcs from a 218-million line access log. Each entry will be benchmarked on a Sun T2000 with support for 32 hardware threads, giving lots of opportunities for parallel processing.</p>
<p>What makes this really interesting is that the project is not only about performance, but rather about writing code that scales to many CPU cores with as little extra programmer effort as possible. Some <a href="http://wikis.sun.com/display/WideFinder/Results">results</a> are already in, with OCaml currently in the lead performance-wise.</p>
<p>Each log line looks something like this:</p>
<blockquote><p>www.example.com - - [17/Jun/2007:21:37:17 -0700] &#8220;GET /ongoing/ongoing.atom HTTP/1.1&#8243; 304 -  - &#8220;-&#8221; &#8220;Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4</p></blockquote>
<p>Eager to bring the performance lead back to C++ where it belongs I started out writing my own implementation using QtConcurrent and the other Qt APIs. Briefly explained, the code uses QtConcurrent::mappedReduced to multi-thread the code, and then QByteArray::split() twice to iterate over each word in each line. The <a href='http://labs.trolltech.com/blogs/wp-content/uploads/2008/06/main.cpp' title='main.cpp'>current version</a> computes the number of hits for each page.</p>
<p>Results: (parsing 100K lines on an 8-core 2.8 GHz Mac Pro)</p>
<p>1 Thread<br />
real	0m2.283s<br />
user	0m1.141s<br />
sys	0m0.249s</p>
<p>2 Threads:<br />
real	0m1.446s<br />
user	0m1.853s<br />
sys	0m0.271s</p>
<p>1.6X speedup.. not too bad.</p>
<p>4 Threads:<br />
real	0m3.186s<br />
user	0m10.643s<br />
sys	0m0.407s</p>
<p>1 second slower that the single-threaded version.. this does not bode well.</p>
<p>8 Threads:<br />
real	0m7.000s<br />
user	0m46.922s<br />
sys	0m0.724s</p>
<p>Seven seconds! We get a nice linear scaling of the run-time as we increase the number of threads, but unfortunately in the wrong direction. The program us spending a lot of user time doing something though, so let&#8217;s run it through Shark and see what&#8217;s going on:</p>
<p><a href='http://labs.trolltech.com/blogs/wp-content/uploads/2008/06/spinlock.png' title='spinlock.png'><img src='http://labs.trolltech.com/blogs/wp-content/uploads/2008/06/spinlock.png' alt='spinlock.png' /></a></p>
<p>80% in a spin-lock used by malloc/free. But who is calling malloc that much?</p>
<p><a href='http://labs.trolltech.com/blogs/wp-content/uploads/2008/06/spinlock-split.png' title='spinlock-split.png'><img src='http://labs.trolltech.com/blogs/wp-content/uploads/2008/06/spinlock-split.png' alt='spinlock-split.png' /></a></p>
<p>Aha.. QByteArray::split(). While being a very convenient API, split() was clearly not designed for heavy parsing like this. Still, I&#8217;d like a less catastrophic impact on the run-time when adding threads, even if the program really is calling malloc/free to often. Let&#8217;s try with the <a href="http://www.malloc.de/en/">ptmalloc</a> memory allocator instead:</p>
<p>8 Threads:<br />
real	0m0.908s<br />
user	0m3.784s<br />
sys	0m0.533s</p>
<p>ptmalloc is used in GNU/Linux though the GNU C library and scales much better on multicore systems. The program itself still does not scale beyond 4 threads, but it does not get significantly worse either when adding threads. I guess it&#8217;s debatable whether or not this is qualifies as a bug in the Darwin memory allocator, but at least ptmalloc shows that it is possible to do better.</p>
<p>That&#8217;s all for now <img src='http://labs.trolltech.com/blogs/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> For the next installment I&#8217;ll try to get better scaling, at the expense of increasing the developer effort.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.trolltech.com/blogs/2008/06/27/wide-finding/feed/</wfw:commentRss>
		</item>
		<item>
		<title>QtWebKit and Gutenbrowser</title>
		<link>http://labs.trolltech.com/blogs/2008/06/23/qtwebkit-and-gutenbrowser/</link>
		<comments>http://labs.trolltech.com/blogs/2008/06/23/qtwebkit-and-gutenbrowser/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 04:13:51 +0000</pubDate>
		<dc:creator>lorn</dc:creator>
		
		<category><![CDATA[Qt]]></category>

		<category><![CDATA[Qtopia]]></category>

		<category><![CDATA[KDE]]></category>

		<guid isPermaLink="false">http://labs.trolltech.com/blogs/2008/06/23/qtwebkit-and-gutenbrowser/</guid>
		<description><![CDATA[After many moons, I have started to work again on my personal project, Gutenbrowser. It is in need of much maintenance and love.
Since Qt finally has a good webview, QWebView, I can finally start working towards version 1.0! With very little work, gutenbrowser can now show Gutenberg Project etexts that come with images. 
Since I [...]]]></description>
			<content:encoded><![CDATA[<p>After many moons, I have started to work again on my personal project, Gutenbrowser. It is in need of much maintenance and love.</p>
<p>Since Qt finally has a good webview, QWebView, I can finally start working towards version 1.0! With very little work, gutenbrowser can now show Gutenberg Project etexts that come with images. </p>
<p>Since I have a macmini at home, I can distribute Mac binaries, as well as Windows and a few Linux embedded devices (Openmoko Neo and possibly Nokia&#8217;s n8&#215;0&#8217;s Qtopia )<br />
and with the help of Petter Reinholdtsen, fix a few bugs and be in the standard Debian distribution.</p>
<p>For those that do not know of the <a href="http://en.wikipedia.org/wiki/Project_Gutenberg">Gutenberg Project</a>, there are over <a href="http://www.gutenberg.org/wiki/Main_Page">25,000 free books</a> available!</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.trolltech.com/blogs/2008/06/23/qtwebkit-and-gutenbrowser/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
