#include "widget.h"
#include <QApplication>
//#include <QDebug>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.resize(400,300);//設定視窗大小
w.move(200,100);//設定視窗位置
w.show();
int x=w.x();
qDebug("x:%d",x);
/*初學者很容易寫成qDebug<<
QDebug<<
QDebug()<<
*/
int y=w.y();
qDebug("y:%d",y);
QRect geometry=w.geometry();
QRect frame=w.frameGeometry();
qDebug()<<"geometry:"<<geometry<<"frame:"<<frame;
return a.exec();
}
******************************************************
直接將字串當做參數傳給qDebug()函數,可以不包含標頭檔:QDebug
否則,使用輸出資料流的方式一次輸出多個值,他們就必須添加標頭檔
******************************************************
缺乏相應的標頭檔出現如下的錯誤:
1)\qDebuf\main.cpp:17: 錯誤:C2027: use of undefined type 'QDebug'
2)qDebuf\main.cpp:17: 錯誤:C2678: binary '<<' : no operator found which takes a left-hand operand of type 'QDebug' (or there is no acceptable conversion)