Line 7: | Line 7: | ||
= Why use Qt Creator = | = Why use Qt Creator = | ||
− | [[ | + | {|align="right" |
+ | |[[image:Snapshot-qtcreator.png|right|thumb|200px|KDE4's ktimetracker loaded as QtCreator project]] | ||
+ | |} | ||
+ | To create your C++ programs you can use any text editor. But life will be much easier if you gain Qt Creator's features, that means | ||
+ | * you can get your source code saved, built and run on one click | ||
+ | * you get code-completion | ||
+ | * you can find all places in your source code where you call a function (e.g. "where do I call refresh()") | ||
+ | * you can go back to a more recent cursor-position with your editor, even if this is in another file | ||
+ | * you can checkout and check in to a subversion or git repository without leaving your workflow | ||
= Creating a new program = | = Creating a new program = | ||
− | |||
Here is a short example how you can create a "hello world" program. For more information read the [http://qt.nokia.com/doc/designer-manual.html user documentation]. | Here is a short example how you can create a "hello world" program. For more information read the [http://qt.nokia.com/doc/designer-manual.html user documentation]. | ||
Languages: عربي | Asturianu | Català | Česky | Kaszëbsczi | Dansk | Deutsch | English | Esperanto | Español | Eesti | فارسی | Suomi | Français | Galego | Italiano | 日本語 | 한국어 | Norwegian | Polski | Português Brasileiro | Română | Русский | Svenska | Slovenčina | Slovenščina | српски | Türkçe | Tiếng Việt | Українська | 简体中文 | 繁體中文
QtCreator is an IDE from Nokia for Qt. It contains QtDesigner for UI design. This article describes:
To create your C++ programs you can use any text editor. But life will be much easier if you gain Qt Creator's features, that means
Here is a short example how you can create a "hello world" program. For more information read the user documentation.
Call Qt Creator
qtcreator
Then select New File or Project -> Qt C++ Project -> Qt Gui Application -> name = helloworld -> Next -> Next -> Finish
Select Edit -> Forms -> mainwindow.ui. Add the widgets you want by drag-and-drop:
Select the mainwindow. This is the one un-intuitive step. To lay out the objects in the mainwindow, you do not select the objects in the mainwindow, but the mainwindow itself.
Select Form -> Lay Out in a Grid
You get a decent look, and if you resize the window, the widgets resize as well.
To use KDE classes like KMessageBox, you need to tell qtcreator to use the KDE libraries when building. Go to your home directory, cd into yourproject and modify yourproject.pro. Add a line
LIBS += -lkdeui
Then you can start using KDE classes in your code.
To add a toolbar, right-click on the UI and choose "Add Toolbar". Then you can set icons and text in your mainwindow's constructor with code like this:
ui->toolBar->addAction(QIcon("/usr/share/icons/oxygen/22x22/apps/ktip.png"),"hello world");
This describes how to use QtCreator to integrate existing KDE 4 applications. It has been tested with QtCreator 1.2.80 and SUSE Linux 11.1 but should work same or similar with every combination. As an example KDE application we use ktimetracker from the kdepim module, other applications should work analog.
You can either work with code on your disk or have QtCreator do the subversion checkout.
/root/kdepim -DCMAKE_INSTALL_PREFIX=/usr/local -DLIB_SUFFIX=64 -DCMAKE_BUILD_TYPE=debugfull
DLIB_SUFFIX=64 means that you want to install your libraries into directories named lib64, not lib. /root/kdepim is where your source code is.
Projects -> Active run configuration=ktimetracker -> build settings -> build steps -> make -> show details -> activate ktimetracker.
Projects -> Active run configuration=ktimetracker -> build settings -> build steps -> make -> show details -> addtional Arguments = -j8