-----工程WindowTest-----
1.-----窗体类型type.cpp-----
#include <QtGui> int main(int argc, char * argv[]) { QApplication app(argc, argv); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); QWidget wgt1(, Qt::Widget);//默认 QWidget wgt2(, Qt::Dialog);//对话框 QWidget wgt3(, Qt::SplashScreen);//启动画面;飞溅屏幕;初始屏幕 wgt1.setWindowTitle("普通窗体"); wgt2.setWindowTitle("对话框"); wgt3.setWindowTitle("闪屏"); wgt1.setGeometry(, , , ); wgt2.setGeometry(, , , ); wgt3.setGeometry(, , , ); wgt1.show(); wgt2.show(); wgt3.show(); app.exec(); ; }
2.窗体状态-----status.cpp-----
#include <QtGui> int main(int argc, char * argv[]) { QApplication app(argc, argv); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); QWidget wgt1(, Qt::Widget);//普通窗体 QWidget wgt2(, Qt::Widget | Qt::FramelessWindowHint);//无框架 QWidget wgt3(, Qt::Widget | Qt::WindowStaysOnTopHint);//总在最前端 wgt1.setWindowTitle("普通窗体"); wgt2.setWindowTitle("无框架"); wgt3.setWindowTitle("总在最前端"); wgt1.setGeometry(, , , ); wgt2.setGeometry(, , , ); wgt3.setGeometry(, , , ); wgt1.show(); wgt2.show(); wgt3.show(); app.exec(); ; }
3.-----窗体布局layout.cpp-----//布局似乎不准确,该是位置和大小
#include <QtGui> int main(int argc, char * argv[]) { QApplication app(argc, argv); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); QWidget wgt1(, Qt::Widget); QWidget wgt2(, Qt::Widget); QWidget wgt3(, Qt::Widget); wgt1.setWindowTitle("图灵"); wgt2.setWindowTitle("丘奇"); wgt3.setWindowTitle("落雁平沙"); wgt1.move(, );//包含框架 wgt1.resize(, ); wgt2.setGeometry(, , , );//不包含框架 wgt3.setGeometry(, , , ); wgt1.show(); wgt2.show(); wgt3.show(); app.exec(); ; }
4.-----最大化最小化maxmin.cpp-----
#include <QtGui> int main(int argc, char * argv[]) { QApplication app(argc, argv); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); QWidget wgt1; QWidget wgt2; QWidget wgt3; wgt1.setWindowTitle("最大化"); wgt2.setWindowTitle("最小化"); wgt3.setWindowTitle("全屏"); wgt1.setGeometry(, , , ); wgt2.setGeometry(, , , ); wgt3.setGeometry(, , , ); wgt1.setWindowState(Qt::WindowMaximized); wgt2.setWindowState(Qt::WindowMinimized); wgt3.setWindowState(Qt::WindowFullScreen); wgt1.show(); wgt2.show(); wgt3.show(); app.exec(); ; }
全屏就不截了,分辨率有点高