Home

OFF-SOFT.net

OFF-SOFT.net

This site is support & information site of WEB,and Software. This site might help you that create software or Web Site…perhaps?[:]

Qt apps with VC + + 2008 Express to debug

Published on| May 11th, 2009 | No Comment.
Let's use the debug macro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "QApplication"
#include "QPushButton"
 
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QPushButton hello("Hello world");
    hello.resize(100, 30);
 
	int ntest=10;
	int *pttest=NULL;
 
	Q_ASSERT(ntest==10);
	Q_ASSERT(ntest!=10);
	Q_ASSERT_X(ntest!=10,"this is ntest!=10."," ? I do't know.");
	Q_CHECK_PTR(pttest);
 
	hello.show();
    return app.exec();
}

Been compiled debug version of the source code of the above, please try to run debug.
In lines 14-15, and the following screen appears.
Here, we confirm that the debugging information, "neglect" please click.


VC + + This is a string of the output of the following information to the debug output.
ASSERT: "ntest!=10" in file .\sample.cpp, line 14
ASSERT failure in this is ntest!=10.: " ? I do't know.", file .\sample.cpp, line 15
In file .\sample.cpp, line 16: Out of memory

Line 13 is correct, and through, 14,15,16 and the errors in the discharge line.

Also been compiled release version, please try to run debug.
Are not output anything, without having to break the normal "Hello world" and a button that appears.

Like the MFC, in the release version, please note that you will be unchecked.

Let's use the output message
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifdef QT_NO_DEBUG
#define QT_NO_DEBUG_OUTPUT
//#define QT_NO_WARNING_OUTPUT
#endif
//	qDebug() << "Debug" のような記述を行う場合のみincludeする
#include <QDebug>
 
#include "QApplication"
#include "QPushButton"
 
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QPushButton hello("Hello world");
    hello.resize(100, 30);
 
	//	デバッグメッセージを出力する
	qDebug("test-Debug");
	qWarning("test-Warning");
	qCritical("test-Critical");
	qFatal("test-Fatal");
 
//	必ず、QT_NO_DEBUG_OUTPUTをチェックする(コンパイルエラーになる)
#ifndef QT_NO_DEBUG_OUTPUT
	qDebug() << "Debug << " << &hello << "Position:" << hello.pos();
#endif
 
	hello.show();
    return app.exec();
}

1 - 7, please note that it is added to the line.
1 - 4 line, the release version, debug / whether to output a warning message.

2 In line with the release version, and have vowed not to output debugging messages.
The third line (I have commented out) in the release version, and have vowed not to output a warning message.


Been compiled debug version of the source code of the above, please try to run debug.
21 in line, I get the following screen.
Here, we confirm that the debugging information, "neglect" please click.


VC + + This is a string of the output of the following information to the debug output.
test-Debug
test-Warning
test-Critical
test-Fatal
Debug <<  QPushButton(0x12feb4) Position: QPoint(0,0) 

Also been compiled release version, please try to run debug.
Without a break, and I close the application immediately.

In the release version, qFatal in and stop the application immediately.
In fact, the debugging information, I think that the following message is printed.

test-Warning
test-Critical
test-Fatal

Thus the MFC debug information can be output to the same.
So, C / C + +, for a memory leak problem that most often? Qt, you should do?


Comments

Leave a Reply







  • はてなブックマークへ追加する
  • Facebookでシェアする
  • twitter でつぶやく
  • Google Plusでシェアする
  • Pocketでシェアする
ページトップへ