(原)Qt之HelloWorld
孔令春
posted @ 2009年9月21日 05:43
in 开发语言
with tags
Qt之HelloWorld
, 5212 阅读
怪了,好像学任何语言都是从Hello world的,呵呵,Qt也不例外。
代码如下:
/* Hello/hello.cpp */
#include <QApplication>
#include <QMainWindow>
#include <QCore/QTextCodec>
#include <QLabel>
int main(int argc, char *argv[])
{
QApplication app(argc,argv);
QTextCodec::setCodecForTr(QTextCodec::codecForName(
"utf-8"
));
QMainWindow *window = new QMainWindow;
window->setWindowTitle("Hello Qt");
QLabel *label = new QLabel("<h2><font color =
red><i>Hello</i></font>"
"<b>World!</b></h2>");
label->setAlignment(Qt::AlignCenter); //居中对齐
window->setCentralWidget(label); //将Label设置为中间部件
window->adjustSize(); //调整窗口到合适大小
window->show();
return app.exec();
}
必須的东西:
#include <QApplication> int main(int argc,char *argv[]) { QApplication app(argc,argv); ... return app.exec(); }
编译:
qmake -project ---生成Qt的项目文件
qmake ---生成MakeFile文件
make ---执行MakeFile文件(调用g++编译)
注意:
生成的项目文件名,默认是与上一级文件夹同名的,所以建议你最好为你的程序单独建一个文件夹。
2022年8月19日 20:40
Tamilnadu Board Model Paper 2023 Class 6 Pdf Download with Answers for Tamil Medium, English Medium, Hindi Medium, Urdu Medium & Students for Small Answers, Long Answer, Very Long Answer Questions, and Essay Type Questions to Term1 & Term2 Exams at official website. TN Board Model Paper Class 6 New Exam Scheme or Question Pattern for Sammittive Assignment Exams (SA1 & SA2): Very Long Answer (VLA), Long Answer (LA), Small Answer (SA), Very Small Answer (VSA), Single Answer, Multiple Choice and etc.
2022年11月10日 23:22
A chartered Account CA holds a significant role in attestation of any document or certificate. It’s a substantiation that document or certificate is legal and the entity and giving the document has approved. UDIN ICAI However, in recent days misleading information is spread by UN certified people posing as chartered accountants. They are issuing and signing certificates and documents illegally, to curb this offence.
2023年1月22日 21:18
K2 challan also referred to as Khajane 2, an integrated financial management system from the Government of Karnataka. The K2 has been brought into working with an aim to manage the financial business of the government. Khajane 2 Login It works to simplify the process of remittance of departments under government by bringing an option of anywhere-anytime payment options. Firstly every department under the government of Karnataka will have access to Khajane 2 which allows their customers to remit to the government through the easy payment links provided.
2024年1月25日 04:56
Board Model Papers 2024 Download with Suggestions for 10th Class Textbooks 2024 Pdf Download and SSLC New Syllabus Sample Question Paper 2024 and different types of model papers boardmodelpaper.com and question papers for following the website and Arts, Science, Commerce Stream Subject Wise Solved Question Bank for Hindi & English Medium Students with Exam Pattern & Blueprint and subject Wise with 11th & 12th Question Bank 2024 for General & Vocational Course Languages & Subjects Important Question for the above link.