<?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>Code Perspective &#187; QT</title>
	<atom:link href="http://codeperspective.ca/tag/qt/feed/" rel="self" type="application/rss+xml" />
	<link>http://codeperspective.ca</link>
	<description>Coding is awesome</description>
	<lastBuildDate>Sun, 28 Mar 2010 16:00:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Creating an Application Specific Console in QT Jambi</title>
		<link>http://codeperspective.ca/2009/03/16/creating-an-application-specific-console-in-qt-jambi/</link>
		<comments>http://codeperspective.ca/2009/03/16/creating-an-application-specific-console-in-qt-jambi/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 04:22:25 +0000</pubDate>
		<dc:creator>Code Perspective Admin</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[QT]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://codeperspective.ca/blog/?p=30</guid>
		<description><![CDATA[I am currently working on a project that required a console with a very specific purpose. It needed to communicate with a custom back-end protocol for use in a client/server environment. This sort of specific tutorial is not surprisingly unavailable online. The first step when setting up an application specific console is actually setting up [...]]]></description>
			<content:encoded><![CDATA[<p>I am currently working on a project that required a console with a very specific purpose. It needed to communicate with a custom back-end protocol for use in a client/server environment. This sort of specific tutorial is not surprisingly unavailable online. The first step when setting up an application specific console is actually setting up the back-end. This is something that will be potentially done as a future tutorial. Anyways back to building the console window. The components included in the console window will be one QTextEdit, and one QLineEdit. This can be constructed in any way you like. The QTextEdit can be on the bottom and the QLineEdit on top or the other way around, that&#8217;s up to you. </p>
<p>Next, we will need to be adding a custom action listener to the QLineEdit so that when the enter key is pressed inside the QLineEdit the command will be sent to the server and then displayed in the QTextEdit window. As a future feature implementation, syntax highlighting could be implemented for an easier display inside the QTextEdit window. The custom action listener to add to the QLineEdit bar looks like this&#8230;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">QLineEdit.<span style="color: #006633;">returnPressed</span>.<span style="color: #006633;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, <span style="color: #0000ff;">&quot;NameOfActionListenerMethod()&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This will ensure that everytime the enter button is pressed, the string that the user entered will be able to be transfered to the server, or wherever else in the program you would like it to go. Now for the action listener method. The method should be declared as public with a return type of void.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> terminalWindowEnterPressed<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        terminalWindow.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>enterArea.<span style="color: #006633;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        enterArea.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Protocol Name &gt; &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Then once you have the action listener built to just send the data to the window, you can do the same with sending it across a network.</p>
<p>All Together the code looks like this. All you have to do is copy/paste the code into your program and use it at will.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #008000; font-style: italic; font-weight: bold;">/**
     *
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> buildTerminal<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        terminalFrame <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> QFrame<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        terminalFrame.<span style="color: #006633;">setWindowTitle</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Window Title&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        terminalWindow <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> QTextEdit<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        terminalWindow.<span style="color: #006633;">setReadOnly</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        enterArea <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> QLineEdit<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        enterArea.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Protocol Name &gt; &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        enterLabel <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> QLabel<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Enter Command&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        terminalFrame.<span style="color: #006633;">setMinimumSize</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">600</span>, <span style="color: #cc66cc;">400</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        enterArea.<span style="color: #006633;">returnPressed</span>.<span style="color: #006633;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, <span style="color: #0000ff;">&quot;terminalWindowEnterPressed()&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        QGridLayout layout <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> QGridLayout<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        layout.<span style="color: #006633;">addWidget</span><span style="color: #009900;">&#40;</span>terminalWindow,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">10</span>,<span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        layout.<span style="color: #006633;">addWidget</span><span style="color: #009900;">&#40;</span>enterArea,<span style="color: #cc66cc;">11</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">9</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        layout.<span style="color: #006633;">addWidget</span><span style="color: #009900;">&#40;</span>enterLabel, <span style="color: #cc66cc;">11</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        terminalFrame.<span style="color: #006633;">setLayout</span><span style="color: #009900;">&#40;</span>layout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        terminalFrame.<span style="color: #006633;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     *
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> terminalWindowEnterPressed<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        terminalWindow.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>enterArea.<span style="color: #006633;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        enterArea.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Protocol Name &gt; &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Cheers</p>
<p><!--digg--></p>
]]></content:encoded>
			<wfw:commentRss>http://codeperspective.ca/2009/03/16/creating-an-application-specific-console-in-qt-jambi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Basic Window in Qt</title>
		<link>http://codeperspective.ca/2009/02/17/creating-a-basic-window-in-qt/</link>
		<comments>http://codeperspective.ca/2009/02/17/creating-a-basic-window-in-qt/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 03:09:46 +0000</pubDate>
		<dc:creator>Code Perspective Admin</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[QT]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://codeperspective.ca/blog/?p=15</guid>
		<description><![CDATA[This is a basic piece of code to get you started with the QT Jambi API. Ensure that you have the QT libraries installed before you try and run this code. IF you don&#8217;t have this then it won&#8217;t run properly and will throw an error. This displays a basic window. Nothing added to it [...]]]></description>
			<content:encoded><![CDATA[<p>This is a basic piece of code to get you started with the QT Jambi API. Ensure that you have the QT libraries installed before you try and run this code. IF you don&#8217;t have this then it won&#8217;t run properly and will throw an error. This displays a basic window. Nothing added to it just a basic QT Jambi Window.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.trolltech.qt.gui.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> basicWindow
<span style="color: #009900;">&#123;</span>
 <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> WINDOW_WIDTH <span style="color: #339933;">=</span> <span style="color: #cc66cc;">500</span><span style="color: #339933;">;</span>
 <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> WINDOW_HEIGHT <span style="color: #339933;">=</span> <span style="color: #cc66cc;">400</span><span style="color: #339933;">;</span>
 <span style="color: #000000; font-weight: bold;">private</span> QFrame frame<span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #000000; font-weight: bold;">public</span> basicWindow<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">//create the frame</span>
  frame <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> QFrame<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//create the size of the window</span>
  frame.<span style="color: #006633;">resize</span><span style="color: #009900;">&#40;</span>WINDOW_WIDTH, WINDOW_HEIGHT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//create the layout for the window</span>
  QGridLayout gridLayout <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> QGridLayout<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//add the layout to the main frame</span>
  frame.<span style="color: #006633;">setLayout</span><span style="color: #009900;">&#40;</span>gridLayout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  frame.<span style="color: #006633;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
 <span style="color: #009900;">&#125;</span>
&nbsp;
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">//Used to initialize the window</span>
  QApplication.<span style="color: #006633;">initialize</span><span style="color: #009900;">&#40;</span>args<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//creates a new instance of the basicWindow</span>
  <span style="color: #000000; font-weight: bold;">new</span> basicWindow<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">//runs the window as an application</span>
  QApplication.<span style="color: #006633;">exec</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Cheers</p>
<p><!--digg--></p>
]]></content:encoded>
			<wfw:commentRss>http://codeperspective.ca/2009/02/17/creating-a-basic-window-in-qt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Swing vs QT Jambi</title>
		<link>http://codeperspective.ca/2009/02/17/swing-vs-qt-jambi/</link>
		<comments>http://codeperspective.ca/2009/02/17/swing-vs-qt-jambi/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 03:07:42 +0000</pubDate>
		<dc:creator>Code Perspective Admin</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[QT]]></category>
		<category><![CDATA[Swing]]></category>

		<guid isPermaLink="false">http://codeperspective.ca/blog/?p=13</guid>
		<description><![CDATA[So I figured I should touch on this as I've been frustrated with this for a while at school. First of all I would like to say how frustrating I think java swing is.... I mean you change one thing in the layout and the entire GUI changes for some reason or another that I cannot explain.... So that is my first topic...]]></description>
			<content:encoded><![CDATA[<p>So I figured I should touch on this as I&#8217;ve been frustrated with this for a while at school. First of all I would like to say how frustrating I think java swing is&#8230;. I mean you change one thing in the layout and the entire GUI changes for some reason or another that I cannot explain&#8230;. So that is my first topic&#8230;</p>
<p>Java GridLayout Vs. QGridLayout</p>
<p>QGridLayout is coded in a way that I found extremely easy to use and manipulate. If you change one thing it doesn&#8217;t change the rest of the GUI and it keeps everything where you want it to be. You have the ability to set how big you want something to be. Then, based on the size of all the components in your display it displays the GUI in an appropriate manner. Overall the QGridLayout wins this battle.</p>
<p>Java Gui Components Vs. QT Components</p>
<p>The methods that swing uses to handle components causes an extreme amount of code that is not useful when creating a GUI. For instance, when creating a group of radio buttons, you must first create the buttons, then add the buttons to whichever group then add each individual button to a panel or something to make them appear in the GUI. This is crazy in my opinion and there is no reason that you cannot add a ButtonGroup to a panel. In QT you can add whatever component you like to a GUI. This radio button example is just that, one example and there are far too many to display here.</p>
<p>This is just some short thoughts on QT vs Swing, however If you try it out yourself then I&#8217;m sure you will find out which is better for yourself. Bye For Now,</p>
<p>Cheers</p>
<p><!--digg--></p>
]]></content:encoded>
			<wfw:commentRss>http://codeperspective.ca/2009/02/17/swing-vs-qt-jambi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
