Qt를 시작합시다: 네번째 이야기 Qt modules

Qt는 다들 아시다시피 Object Oriented Programming Toolkit 입니다.
따라서 많은 Object들로 구성되어 있고, 해당 오브젝트들을 어떻게 잘 활용할 수 있느냐가 Application 생산성에 막대한 영향을 끼칠 수 있습니다.

Qt Application 개발시 qmake를 통하여 project를 build한다면 QtCore와 QtGUI 모듈이 Default로 포함됩니다.
다른 말로 표현 하자면 Qt Application 개발 시 자신의 프로젝트 파일(*.pro) 파일에
모듈에 관련된 아무런 추가 삭제를 하지 않으면,  디폴트 모듈로 QtCore 와 QtGUI 모듈이 포함 된다는 뜻입니다.
만일 Widget을 사용하지 않고 Text Based Console Application을 작성한다면
아래와 같이 QT (qmake variable)에서 gui를 빼주면 됩니다.

QT -= gui

반대로 QtWebkit 모듈을 추가 하고 싶다면 아래와 같이 QT(qmake variable)에서 webkit을 더해 주면 됩니다

QT += webkit

소프트웨어 개발 시 사용되는 일반 Qt Module들

QtCore Default로 포함되는 Qt Module로써
다른 모듈에서 사용되는 non-graphic Core 클래스들
주목해야 할 중요 클래스 QObject와 Event Loop
예) Qt Event Loop, 멀티쓰레드, 파일관련 클래스, 스트링 버퍼 등등
QtGui Default로 포함되는 Qt Module로써
Graphical user interface (GUI) 컴포넌트
QWidget과 같이 직접적으로 UI를 구성하게 되는 클래스들

예) PushButton, Bitmap, Cursor, Image등등

QtMultimedia 로우레벨 멀티미디어 함수들을 지원하는 클래스 모듈

System specific 한 저수준 함수들
Application 개발자들의 경우는 Phonon module을 통하여 자동적으로사용되게 된다.

QtNetwork 네트워크 프로그래밍에 관련된 클래스 모듈
QtOpenGL OpenGL 지원에 관련된 클래스 모듈
QtOpenVG OpenVG 지원에 관련된 클래스 모듈
QtScript Qt를 통한 Scripting을 지원하는 클래스 모듈
QtScriptTools Qt Script 엔진의 디버깅 클래스 모듈
QtSql SQL을 사용하는 데이타베이스 클래스 모듈
QtSvg SVG 형식의 파일을 지원하는 클래스 모듈
QtWebKit 웹 콘텐츠를 수정하거나 랜더링 하는데 사용되는 클래스 모듈
QtXml XML을 핸들링 하는데 사용되는 클래스 모듈
QtXmlPatterns XQuery & XPath, XML Schema validation등을 지원하는 클래스 모듈
QtDeclarative QML engine, animation 스크립트, dynamic contents 등과의 연결을 지원하는 클래스 모듈
Phonon Multimedia framework 클래스 모듈

Phonon은 하이레벨 멀티미디어 framework로
Cross platform multimedia 함수들을 지원합니다.

Qt3Support Qt 3.x대와의 호환성을 지원하는 클래스 모듈

Qt Tool과 관련된 모듈들

다른 개발을 위한 모듈들은 QT+=<모듈예약어>를 사용하게 되지만, Qt Tool에 관련된 아래 모듈은
CONFIG+=<모듈예약어>를 사용하게 됩니다.예)  CONFIG += help
QtDesigner Qt Designer 기능 확장을 위한  모듈
QtUiTools Qt Designer 기능 확장을 위한  모듈 Application내에서
Qt Designer form을 핸들링 하기 위한 클래스 모듈
QtHelp 온라인 Help를 위한 클래스 모듈
QtTest 유닛 테스트를 위한 클래스 모듈

Unix 개발자를 위한 Qt Module

QtDBus Unix의 D-Bus 프로토콜을 이용하여
프로세스간 Inter process (IPC)를 지원하는 클래스 모듈


Blog Topics:

Comments

?
Cyrille Berger
0 points
175 months ago

Cool, would be nice to see someone make it works with cmake :) (not me, I am infinitely too lazy)

?
Nathan
0 points
175 months ago

How hard would it be to make this same program work with any set of unit tests? Say I want to use the same pretty interface for the unit tests on my own OSS project. Can I cherry-pick this program and fill it in with my list of auto-tests, or is it not ready for that yet?

?
razvanpetru
0 points
175 months ago

I'm as curious as Nathan: can this be used for generic autotests?

?
Yoann Lopes
0 points
175 months ago

@Nathan, @razvanpetru
Yes I thought about that, and it would not require a lot of modifications. It currently parses the auto-tests project file (auto.pro in tests/auto), so it could just take any .pro file as input instead. I will definitely look into that.

?
Robin Burchell
0 points
175 months ago

I wonder, how does this handle the GUI unit tests? Some months ago, I started work on my own test running tool (http://gitorious.org/qt-com...) as part of the community integration project I was working on at the time (http://blog.rburchell.com/2...), but one of the stumbling blocks I got stuck on at the time was that reliably creating and tearing down a test instance (dbus, GUI with no WM/styles, etc) was a lot of work.

I guess I'm going to have to look into this again sometime soon as I want to start revisiting the community integration stuff.

I'd also just like to add: great news! This is exactly the sort of thing I hope to see a lot more of after writing about the frustrations that many are feeling with trying to contribute to Qt (see http://blog.rburchell.com/2...).

?
Yoann Lopes
0 points
175 months ago

@Robin
It is a bit problematic for GUI tests indeed... For now you can't do anything at the same time for these tests. I'm not sure what to do about that...

@Siddharth
Thank Shane and Liang for that :)

@Rohan
Like Bjørn Erik said, the idea is just to have some helper tool to automate and speed up things so I don't think your first point is relevant.
For your second point you are right, ideally the tool should query the list of tests from some server, but then it closes the door to running external auto-tests. Or then we need a different mode for Qt auto-tests and external auto-tests...

?
mgoetz
0 points
175 months ago

Is this blog entry linked from our contribution model help pages? :)

?
Siddharth
0 points
175 months ago

+2 kudo points for making it work on Symbian. Thank you.

?
Rohan McGovern
0 points
175 months ago

I have a couple of suggestions:

First, the test running logic shouldn't be implemented in this tool, because then it can't be reused in automated systems. e.g. this tool probably runs the tests in a slightly different way than the Qt Continuous Integration system itself does - especially for the more complex things such as running of autotests on symbian devices.

Second, the parsing of test definitions from the .pro files probably shouldn't be done here, because it's more error prone than proper build system integration - this tool might have a different idea about what is/isn't a testcase than other systems which are trying to run the tests. The build system knows `make check' and ideally that's the one canonical way to determine what is and isn't a testcase.

?
Bj&#248;rn Erik Nilsen
0 points
175 months ago

@ Rohan

I believe Yoann wrote this nifty tool to make it easier to run Qt auto tests (tests/auto/*). His goal was clearly not to make a swiss army auto tester tool supporting every single use case without being good at anything. To put it simple; it is a replacement for the following workflow:
cd $class ./tst_$class cd .. cd $anotherClass ./tst_$anotherClass cd ..

... it even supports running tests in parallel :-)

?
Robin Burchell
0 points
175 months ago

@Yoann Lopes
A cross platform solution is... yeah, going to be difficult, if possible at all. The solution I settled on (as I only run Linux) at the time, was to run an Xvfb instance via QProcess. I'm happy to help contribute to make that happen if it's something you'd like to see.

However...
I noticed that some tests don't seem to like Xvfb (unreliable failures), using Xephyr instead made tests pass, but meant that I had to have an annoying window hovering around. Never figured out why. :)

?
Jens Stockhausen
0 points
175 months ago

That's a really nice (and fancy looking) tool. Having a test suite for making sure that nothing is broken by your own changes is a must.
What I'd like to see is something like this tool integrated into QtCreator so that real TDD is possible. If you have tried it you will not write code without tests anymore. So no only generating a new class via the QtCreator templates but also a corresponding UnitTest and running it automatically after compile would be a dream.

?
Alex
0 points
175 months ago

This a more general question: how can QGraphicsSceneEvents be simulated in unit testing? QTest has support for QWidget events (like QTest::keyEvent) but not for QGraphicsWidgets.

?
Yoann Lopes
0 points
175 months ago

@Alex
Just create the event and send it to the scene with QApplication::sendEvent().

?
Alex
0 points
175 months ago

@Yoann
Since events like QGraphicsSceneMouseEvent have no public constructor or property set methods I thought there might be established way to create and send them.

?
Etienne Savard
0 points
175 months ago

I agree 100% with Jens Stockhausen. TDD helpers in QtCreator are a must.

?
Gerolf
0 points
175 months ago

Yes, TDD in QtCreator would be really nice. Perhaps, the Test tool could be part of the qmake project file and be run automatically after building? so it would not opnly be integrated in QtCreator, but in all qmake build process...

?
jarne
0 points
175 months ago

Second the integration of some test-driven development features into QtCreator. If you compare use of QTestLib with QtCreator to, e.g., the JUnit tools available in Eclipse...

I would really like to see something comparable in QtCreator :-).