utorak, 16. lipnja 2009.

Adding a Qt Widget

In the previous post, I explained how we managed to get the widgets to show and all that mess.

Now it's time to get one to work. I chose the qgauge widget.

After creating/opening your project and dragg-and-dropping your widget to the appropriate place on the in the appropriate .ui file, there are the following things that remain to be done:

1. copy the widget .cpp and .h (source) files to your project folder. For QGauge it's qgauge.cpp and qgauge.h files. If you want them elsewhere you have to modify the includes throughout the project.
2. Edit the .pro file in the following manner:

ORIGINAL:
#-------------------------------------------------

#

# Project created by QtCreator 2009-06-16T09:22:14

#

#-------------------------------------------------

TARGET = QtTest2

TEMPLATE = app

SOURCES += main.cpp\

qtmain.cpp\

HEADERS += qtmain.h

FORMS += qtmain.ui



Edited:


#-------------------------------------------------

#

# Project created by QtCreator 2009-06-16T09:22:14

# edited by 2rbo

#-------------------------------------------------

TARGET = QtTest2

TEMPLATE = app

SOURCES += main.cpp\

qtmain.cpp\

qgauge.cpp

HEADERS += qtmain.h

HEADERS += qgauge.h

FORMS += qtmain.ui


aaaaaaaaaaaaaaaaaaaaaaaaand... it doesn't work - if you're on Windows! :) You'll need to edit the qgauge.h file in the following manner:

class /*QDESIGNER_WIDGET_EXPORT*/ QGauge : public QWidget

For details, check the following forum post.

ponedjeljak, 15. lipnja 2009.

QtCreator beginnings....

I made an Ooboonto reminder blog in order to store all the hard-found knowledge I gathered around the forums on Ubuntu stuff. Now it's Qt time.
The tutorials here will be "for dummies" and rather long winded, at least at the beginning... basically they're for ME, but if they help someone else out it'll be great!

We have opted to finally use QtCreator instead of VS 2005/2008. Why? No real reason! :) I'm kidding; the truth is - VS is still the superior development tool. And with the upcoming 2010 version I'm sure it's gonna be even better.

The thing is, I want to do my development in Ubuntu environment (stabile x64, bash, compiz, you know - the works...), and for some reason QtCreator looks more appealing to me than Eclipse. Maybe because it's "inner logic" is closer to VS which I'm used to... and being a lousy programmer that I am, this is rather important to me.

Here's a forum entry where a colleague of mine posted what we discovered in our first time around with QtCreator 1.0 . What we forgot to document, is how to finish the procedure! So in order for me not to forget it again, here's what to do...

1.1. As "Stefan" says; you're to follow the given procedure:

1] download qt-creator-1.0.0-src.zip
2] open qtcreator.pro with existing Qt Creator
3] build release
4] run new qtcreator.exe
5] you have all designer plugins from C:\Qt\2009.01\qt\plugins\designer

What you should do next is turn off both copies of the QtCreator, and check out the folders you got. Here's a screenshot on what you should have gotten. On the left pane is the SDK version; and on the right the re-compiled one.



What you should do now is:
1. delete (or rename) the "bin" and "lib" in c:\Qt\2009.01 (the SDK version)
2. copy the "bin" and "lib" folders from the re-compiled version and paste them into c:\Qt\2009.01\
3. Start QtCreator via shortcut (or from c:\Qt\2009.01\bin\qtcreator.exe)
4. Open a Qt project and double-click it's .ui file to get into the designer view

The essential thing to get is that you need to replace all the SDK-built files in "bin" and "lib" folders with the re-built files; otherwise the thing won't work. Assumably this is fixable by messing with the Enviroment Variables and PATH to mingw and something else, but I didn't into that... If anyone has a full tutorial for that procedure, I'd appreciate the link.

Anyway: what you shoud now be getting is THIS:


OK, it's a small pic but you can see extra sample widgets in the lower section; meaning the bloody thing WORKS now! :)

OK, let's try adding a custom widget now.

My fav place to download widgies is http://www.qt-apps.org/. So we'll download something from there, say QtGauge (yeah, I'm an engineer so sue me). What I did is:
1. download the qgauge beta 2
2. unpack
3. open qtgaugeplugin.pro with QtCreator
4. build release (Build -> Set Build Configuration -> Release; if this is grayed out double click a project file, maybe qgauge.cpp so it opens)

Then, we implement it into QtCreator:
1. go to your QGauge folder and into the release folder, on my comp the path is C:\Qt\widgets\QGauge020\release, and copy the qgaugeplugin.dll and qgaugeplugin.a files
2. Paste it into C:\Qt\2009.02\qt\plugins\designer\ folder

After restarting the QtCreator (open a project, hit it's .ui file so you get into the Designer...). You should see an extra tab "Lab Widgets" and your QGauge thingy in it, like this:



..And it seems to not work, but it's not due to QtCreator... tune into next post to see 'sup.