PDA

View Full Version : Single Log File for Qt Project.



qtlinuxnewbie
10th February 2010, 13:08
hi,

i have a QT project in Linux with 4 windows(corresponding .cpp..h etc.,).
i want to maintain a single Log file for all the 4 windows.
how can i do that?:confused::confused:

Actually i tried creating the file and opening in main.cpp but it cannot be used in other .cpp files,
how can i use this file pointer in other windows. i tried with extern keyword but it is not working.

Thanks in advance.

vishwajeet.dusane
10th February 2010, 16:48
Have a look at QtMsgHandler qInstallMsgHandler ( QtMsgHandler handler ) function in qt assistant. that will be usable in ur case

qtlinuxnewbie
11th February 2010, 10:22
i dint find much information about
QtMsgHandler.
Could you direct me .

Lykurg
11th February 2010, 10:29
you can use the singleton approach for passing the pointer to your four windows. But better you use the solution vishwajeet.dusane suggested you. To find informations use the assistant: On the left choose the tab "index" and type inside the search field "qInstallMsgHandler".

Or use the online documentation: QtGlobal::qInstallMsgHandler().

qtlinuxnewbie
16th February 2010, 12:39
i want to use the singleton approach..
so how can i pass the File pointer..
could u suggest singleton

Lykurg
16th February 2010, 13:00
Have a look at our wiki: Singleton_pattern.