Qt Demo Script
Jump to navigation
Jump to search
This is a short introduction to Qt using a simple demo script. We play around with strings and look into the issue how to present them.
Let's get started.
Main function
<br />#include <QtCore&gt;
int main(int argc, char **argv)<br />{<br /> // sample code goes here<br />}<br />
Fun with Strings
<br />QString s1("Hello&quot;);<br />QString s2("World&quot;);<br />QString s = s1 + " " + s2;<br />qDebug() << s; // "Hello World&quot;<br />
This is easy.
List of Strings
<br />QList&lt;QString&gt; list;<br />list << s1 << s2;<br />qDebug() << list;<br />// or<br />list = s.split(" "); // "Hello World&quot; => ["Hello&quot;, "World&quot;]<br />
QStringList
<br />QString s("Hello World&quot;);<br />QStringList list = s.split(" ");<br />QString s2 = list.join(" ") + "!";<br />QDebug() << s << " => " << list; << " => " << s2; // "Hello World => ["Hello&quot;, "World&quot;] => "Hello World!"<br />