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.

Nema komentara:

Objavi komentar