You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Wednesday, August 1st 2007, 5:39pm

QMessageBox and qDebug in QT Library application

Hi

How to determine QT application type from QT Library?

Also how to make the QT library to display the output in QMessageBox or qDebug() based on the type of application?

Your Support and Help are greatly appreciate.
Thanks in advance.

Thx
Senthil
smart work :-)

goer

Beginner

  • "goer" is male

Posts: 44

Location: Ukraine

Occupation: http://www.linkedin.com/in/gorishnii

  • Send private message

2

Wednesday, August 1st 2007, 7:05pm

RE: QMessageBox and qDebug in QT Library application

Hi!

The type of QT application is known during development stage? Or I don't understand subject?

Regarding the QMessageBox vs qDebug(). Do you understand that it's different tools of Qt framework?

Regards.

This post has been edited 1 times, last edit by "goer" (Aug 1st 2007, 7:07pm)


3

Thursday, August 2nd 2007, 6:16am

RE: QMessageBox and qDebug in QT Library application

Hi

Thanks for your reply.

First let me give some brief expalination about my need.

I am developing a QT Library. The library will used by QT GUI application or QT console application.

My expectation is that the QT library implementation should be in such a manner that
Whenever it is linked with QT GUI application , it should display the message in QMessageBox.
Whenever it is linked with QT console application , it should display message in the console using qDebug();

Since I am new to QT area , am not able to know how to proceed further in this.

Thx
smart work :-)

ct313

Trainee

  • "ct313" is male

Posts: 127

Location: Viet Nam

Occupation: Software Developer

  • Send private message

4

Thursday, August 2nd 2007, 7:14am

RE: QMessageBox and qDebug in QT Library application

Hi senthilSP,
you note that command qDebug() only show yourmessage when you run your program in mode debug.(Ex: in VC6.0, when you press F5 to build your program)
And QMessageBox will show you messagebox in app type QWidget, QDialog,... not show in console mode.
When you believe in yourself, the other can be your !!!

5

Thursday, August 2nd 2007, 7:18am

RE: QMessageBox and qDebug in QT Library application

Hi

Thanks for your reply ...
Got some required information from your reply.
Hope I am proceeding in the right direction to meet my need.

Thx
smart work :-)

goer

Beginner

  • "goer" is male

Posts: 44

Location: Ukraine

Occupation: http://www.linkedin.com/in/gorishnii

  • Send private message

6

Thursday, August 2nd 2007, 10:50am

RE: QMessageBox and qDebug in QT Library application

Sorry if I don't understand your needs.

Let me give you some quote from QT Assitant:

Quoted


void qDebug ( const char * msg, ... )

Calls the message handler with the debug message msg. If no message handler has been installed, the message is printed to stderr. Under Windows, the message is sent to the debugger. This function does nothing if QT_NO_DEBUG_OUTPUT was defined during compilation.
If you pass the function a format string and a list of arguments, it works in similar way to the C printf() function.
Example:
qDebug("Items in list: %d", myList.size());
If you include <QtDebug>, a more convenient syntax is also available:
qDebug() << "Brush:" << myQBrush << "Other value:" << i;
This syntax automatically puts a single space between each item, and outputs a newline at the end. It supports many C++ and Qt types.
Warning: The internal buffer is limited to 8192 bytes, including the '\0'-terminator.
Warning: Passing (const char *)0 as argument to qDebug might lead to crashes on certain platforms due to the platform's printf() implementation.
See also qWarning(), qCritical(), qFatal(), qInstallMsgHandler(), and Debugging Techniques.


As you see qDebug use stderr device. Maybe correctly will use cout for output to console?

Regarding type of app. I don't know how determine its at the time of compilation stage. I only know that type of qt app define in pro-file. I think one of way to define some parameter in interface of your library, which is control output stream.