Showing posts with label Qt. Show all posts
Showing posts with label Qt. Show all posts

Tuesday, September 29, 2009

How to create custom widgets

First, create your custom widget use Qt creator. To wrap up, do the following:

In Interface.h file:

#include QtDesigner
#include "PushButtonPlugin.h"
#include "AnimatedLabelPlugin.h"
#include "LabelPlugin.h"
#include "TextEntryPlugin.h"

//Interface for all Widgets
class MyCustomWidgets: public QObject, public QDesignerCustomWidgetCollectionInterface
{
Q_OBJECT
Q_INTERFACES(QDesignerCustomWidgetCollectionInterface)

public:
MyCustomWidgets(QObject *parent = 0) : QObject(parent)
{
widgets.append(new PushButtonPlugin(this));
widgets.append(new AnimatedLabelPlugin(this));
widgets.append(new LabelPlugin(this));
widgets.append(new TextEntryPlugin(this));
}

virtual QList customWidgets() const
{
return widgets;
}

private:
QList widgets;
};

In Interface.cpp file:
#include "Interface.h"

Q_EXPORT_PLUGIN2(customwidgetsplugin,MyCustomWidgets);

Monday, August 10, 2009

How to build Qt

Steps on how to build Qt:

1. Download Qt version 4.5 from the web server (google it):

search for "qt-win-opensource-src-4.5.0-rc1.zip"

2. If you happened to find Qt4.5 on the website, make sure to download the “zip” version instead of the “exe” version. This will ensure “nmake” to compile under windows operating system.

3. Extract the zip file into a folder, for instance, C:\Qt\qt4.5\

4. Install DirectX 9.0 on your computer under, let’s say C:\DXSDK directory. The installation file for DirectX 9.0 can be found in the following server directory:

\\lab-542\GM\Software Releases\TOOLS\DirectX\dx90bsdk.exe

5. Install the most updated version of Microsoft DirectX SDK on your computer.

6. Bring up a Dos command prompt from Visual Studio 2005

7. Add the following to the environment variables: ( attention!! follow the order, the include and lib directory of Direct X 9 should be in front of any other include and lib directories )

DXSDK_DIR = C:\Program Files\Microsoft DirectX SDK (February 2007)\

(February 2007)

Path = C:\Qt\qt4.5\bin
Include = C:\DXSDK\Include; DXSDK_DIR\Include
LIB = C:\DXSDK|Lib; DXSDK_DIR\Lib

8. At the dos command prompt, goto C:\Qt\qt4.5\

9. type “configure –platform win32-msvc2005 -phonon” to include phonon module in the build process. choose “y”. This will create makefiles for each related module.

10. Type “nmake” under C:\Qt\qt4.5, this will build all the modules, such as “Demo Examples”, “Network”, “Sql”, “Phonon”, etc. one by one.

11. Make sure the phonon module is built successfully, and then go to
C:\Qt\qt4.5\src\plugins\phonon, and type “nmake”. This will build phonon backend plugins.

The following audio and video format will be supported under Qt4.5
For Audio:

AIFF
BASIC
MID
MIDI
MP3
MPEG
MPGURL
MPG
WAV
X-AIFF
X-MID
X-MIDI
X-MP3
X-MPEG
X-MPEGURL
X-MPG
X-MS-WAX
X-MS-VMA
X-WAV

For Video

AIV
MPEG
MPG
MSVIDEO
X-MPEG
X-MPEG2A
X-MS-ASF
X-MS-ASF-PLUGIN
X-MS-WM
X-MS-WMV
X-MS-WMX
X-MS-WVX
X-MSVIDEO

Friday, July 31, 2009

The Qt Resource System

Go to http://doc.trolltech.com/4.5/resources.html

to produce a binary rcc file, use the following command:

rcc -binary myresrouce.qrc -o myresrouce.rcc

Tuesday, July 28, 2009

how to compile resource file in Qt

A resource file tells the location of the images defined in the ui file. It needs to be compiled in order for the code to use. Hopefully, in the resource file, the alias are defined, so that the relative path is used for each image, and therefore good for the portability.

To compile the resource file (resource.qrc) under the visual c++ environment, make sure the compiler knows the path of Qt.

Go to the bin path under Qt, for instance, cd C:\Qt\bin
type "rcc path\resource.qrc -o path\resource.rcc"

This will create rcc file which is recognized by the compiler.