PDA

View Full Version : Help sought on console + GUI Integration...



mysearch05
27th January 2006, 08:19
hi

i m new to QT programming and i m to design an application getting data from the network (tcp) and displaying it on a frontend (GUI). i want to build up the application in QT. Further, i will be having more than one GUI-windows.My studies about my requirements and QT show that i need a multi-threaded QT application.Please help me regarding:
1) Can i have multiple GUI windows in a multi-threaded QT application? I want my main GUI to call child-windows/widgets as and when required. Is it possible?
2) How to start i.e. whether i should start with a GUI based QT application or simply with a Console application?
3) Can i make use of QT Designer for writing such an application GUI?
4) I want my GUI thread to be active always (and worker threads to work independently). How to achieve this?
5) Further, for posting data from threads to GUI, where should the postEvent and allied code should be written and how it will be received in the GUI thread?

I have gone through all posts regarding this topic on the old forum, got some info also. But still i feel lost on the subject.

Sorry for such a long query BUT i have tried to list out all related queries in a single post only.Hope the same information can help many other developers also.

A sample code/ Pseudocode/ Outline will be of great help.I hope to get an answer in order to join hands with QT development community.

Thanking in advance....

mysearch05
27th January 2006, 08:23
hi
forgot to mention.
Currently i m using Qt3.3.4. Is that ok? or will switching to Qt4.1 be helpful?

Thanks...

jacek
27th January 2006, 08:47
1) Can i have multiple GUI windows in a multi-threaded QT application? I want my main GUI to call child-windows/widgets as and when required. Is it possible?
Yes, you can, but all windows should be managed by the GUI (a.k.a main) thread.


2) How to start i.e. whether i should start with a GUI based QT application or simply with a Console application?
Don't bother with console --- you will have to make the same thing twice later.


3) Can i make use of QT Designer for writing such an application GUI?
Yes, but remember that it isn't IDE, only a layout editor. Read this (http://doc.trolltech.com/3.3/designer-manual-6.html)


4) I want my GUI thread to be active always (and worker threads to work independently). How to achieve this?
Just don't block the GUI thread. You can use custom events to comminicate with other threads.


5) Further, for posting data from threads to GUI, where should the postEvent and allied code should be written and how it will be received in the GUI thread?
http://doc.trolltech.com/3.3/qcustomevent.html

mysearch05
27th January 2006, 10:43
:) thanks dear
can you please comment on following two:

4) I want my GUI thread to be active always (and worker threads to work independently). How to achieve this?
***Just don't block the GUI thread. You can use custom events to comminicate with other threads***

How to achieve this?

And

I m planning to use QT3.3.4. Is that OK or should I use QT 4.1??

I mean all these questions can be very trival to you but confusing for a newcomer for me...

Thanks...

high_flyer
27th January 2006, 12:53
thanks dear
OT:
Hehe, I know you were only trying to be nice mysearch05, but this is usually used between lovers.
So if you are a girl or gay, then ok, but if not, then... well, just for info :)

yop
27th January 2006, 17:59
The book Gui Programming with Qt3 has an excellent chapter on QThread and it's usage. I've used it to move a lengthy printing operation to a new thread and keep my gui responsive. AFAIK it's freely available online (I own a hard copy so I can't give you a direct link but google is always there ;))

GreyGeek
27th January 2006, 20:06
...
I m planning to use QT3.3.4. Is that OK or should I use QT 4.1??
...
Thanks...
It would be better to start with QT 4.1 than 3.3 for a couple of reasons.

First, 3.3 is old and going away, (I haven't heared of anyone developing with 1.x or 2.x Qt lately) so why not start out with the newest and learn it.

Second, the development paradigm of 3.x is much different than 4.x

I started my Qt experience with 3.3 and all the time I used learning how to use the 3.3 Designer to build an app was lost when the 4.x Designer came out. The 3.3 Designer has a GUI RAD quality, and it would create form_ui.h automatically. A lot of mental effort went into learning how to get classes, functions, signals and slots stuffed into form_ui.h. When TrollTech released 4.x the Designer lost all of that functionality and is now just a UI designer, nothing more. IMO, it is for the better because now classic C++ design paradigms apply. Using Qt4 is easier and more powerful. You don't tunnel down into generated files trying to find the best place to make a modification or add some functionality, only to discover a "don't edit the code" sign. As a coder you are responsible for main.cpp, yourapp.h, yourapp.cpp and yourform.ui. When you compile the MOC creates ui_yourform.h, and some other files, but you never concern yourself with them You just deal with the *.h, *.cpp and *.ui files that YOU create.

Having learned both ways I much prefer the "Qt4 way".

I wrote about it here (http://www.qtcentre.org/forum/attachment.php?attachmentid=46&d=1137612186)

jacek
28th January 2006, 14:41
4) I want my GUI thread to be active always (and worker threads to work independently). How to achieve this?
***Just don't block the GUI thread. You can use custom events to comminicate with other threads***

How to achieve this?
There's an example in the docs: http://doc.trolltech.com/3.3/qcustomevent.html