Qt - Qt's brief and coordinate system

A .Qt Creator Project Profiles

Qt Creator project on the way to manage the source code
file A. Qt Creator project contains a different type of
.pro project description file
.pro.user user profile
.h header file
.cpp source file
.ui interface description file
resource files - pictures, audio, etc.
B.pro project description file basic structure
Qt - Qt's brief and coordinate system
C.pro senior project description file variable
Qt - Qt's brief and coordinate system
D.CONFIG used to set the project configuration and compilation options
CONFIG common options
available 1.debug- build debug versions execution of the program
2.release-- build release version of the executable program
3.debug_and_release-- together to build debug version and release version
4.warn_on-- as much output warning information
5.warn_off- can not output a warning message
.pro file Qt is the essence of the Makefile
Qt - Qt's brief and coordinate system
.pro project file analysis

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = HelloWorld
TEMPLATE = app

INCLUDEPATH += E:/BCC/include \
               E:/VC/include

SOURCES += Main.cpp \
           HelloWorld.cpp

HEADERS += HelloWorld.h

FORMS   += HelloWorld.ui

RC_FILE += MyIco.rc

LIBS    += -LE:/vlc-1.11/sdk/lib

CONFIG  += warn_on debug

#
# if 'debug' option is set for CONFIG
#
CONFIG(debug) {
    DEFINES += DEBUG_LOG
    SOURCES += DebugLog.cpp
    HEADERS += DebugLog.h
}

In general, the project file are described using a relative path strength, while the relative path with respect to the project file itself, Qt Creator target project files
Note: 1.Qt Creator open project file is generated at the same time. pro.user file
2..pro.user local configuration file contains information related to the Qt
3. when required when moving between different computer source project, proposed to delete the file .pro.user

E.工程中的概念
构建--对项目的所有文件进行编译,最终生成可执行文件
debug--可以进行程序调式的构建版本,可执行程序中包含调试信息,运行效率不高
release版--最终发布的应用程序构建版本,无调试信息,运行效率高
小结
1.Qt Creator以工程项目的方式对源码进行管理
2.一个Qt Creator工程包含不同类型的文件
3..pro文件是Qt中与平台无关的Makefile文件
4.Qt Creator提供了开发所必备的快捷高效的功能

二.窗口组件及窗口类型

1.图形用户界面由不同的窗口和窗口组件构成
2.<QtGui>头文件包含窗口组件,对应Qt的GUI模块
3.Qt以组件对象的方式构建图形用户界面
4.组件的类型--a.容器类(父组件):用于包含其它的界面组件; b功能类(子组件):用于实现特定的交互功能
Qt - Qt's brief and coordinate system
A.QWidget类继承自QObject类和QPainDevice类
1.QObject是所有支持Qt对象模型的基类
2.QPainDevice是所有可绘制组件的基类
Qt - Qt's brief and coordinate system
B.QWidget组件
1.QWidget能够绘制自己和处理用户的输入
2.QWidget是Qt中所有窗口组件类的父亲
3.QWidget是所有窗口组件的抽象
4.Qt中的每一个窗口组件都是一个QWidget
5.QWidget类对象常作为父组件或顶级组件使用
C.QLabel组件
1.QLabel用于显示一个提示性的字符串
2.QLabel是功能性组件,一般需要父组件作为容器
3.QLabel可以作为窗口存在,但没什么意义
QWidget组件和QLabel组件代码示例

#include "Widget.h"
#include <QApplication>
#include <QLabel>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QWidget w;
    QLabel la(&w);

    w.setWindowTitle("dandanxiaohai");
    la.setText("mylove");
    w.show();

    return a.exec();
}

运行结果
Qt - Qt's brief and coordinate system
D.Q中可以根据需要定制窗口式样
1.窗口类型--Qt::Dialog-对话框类型 ,Qt::window-主窗口类型,Qt::SplashScreen-启动画面类型,其它的类型可以在Qt帮助文档中进行查找
2.窗口标志
Qt::WindowStaysOnTopHint ,Qt::WindowContextHelpButtonHint等
小结
1.Qt以组件对象的方式构建图形用户界面
2.QWidget类是所有用户界面组件的父类
3.QWidget类对象常作为父组件或顶级组件使用
4.Qt中可以根据需要定制窗口式样
5.QLabel用于显示一个提示性的字符串

三.Qt中的坐标系统

A.坐标系统
1.GUI操作系统都有特定的坐标系统
2.图形界面程序在坐标系统中进行窗口和部件的定位
3.定位类型--顶级窗口部件定位、窗口内部件的定位、窗口部件大小设置
B.Qt坐标系统
1.Qt使用统一的坐标系统定位窗口部件的位置和大小
2.Qt部件类提供成员函数在坐标系统中进行定位
3.QWidget类提供了窗口部件所需的坐标系统成员函数
Qt - Qt's brief and coordinate system
QWidget类中的坐标系统成员函数
Qt - Qt's brief and coordinate system
编程实验,代码示例

#include "Mainwindow.h"
#include <QApplication>
#include <QDebug>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Widget w;//顶级组件
    w.resize(300,200);//设置的大小
    w.move(120,120);//设置的生成坐标位置
    w.show();

    qDebug()<<"QWidget:";
    qDebug()<<w.x();
    qDebug()<<w.y();
    qDebug()<<w.height();
    qDebug()<<w.width();

    qDebug()<<"QWidget::geometry()";
    qDebug()<<w.geometry().x();
    qDebug()<<w.geometry().y();
    qDebug()<<w.geometry().height();
    qDebug()<<w.geometry().width();

    qDebug()<<"QWidget::frameGeometry()";
    qDebug()<<w.frameGeometry().x();
    qDebug()<<w.frameGeometry().y();
    qDebug()<<w.frameGeometry().height();
    qDebug()<<w.frameGeometry().width();

    return a.exec();
}

打印结果--在窗口显示之后才会有坐标数据(须在show()调用之后),该打印结果与之前图所示相符合
Qt - Qt's brief and coordinate system

C.QPushButton assembly
1.QPushButton for accepting user click event
2.QPushButton capable of displaying a character string indicative
3.QPushButton functional components, requires the parent container assembly as
4.QPushButton can be positioned in the parent component
Qt - Qt's brief and coordinate system
summary
1. Qt geographic coordinates of the upper left corner is scheduled - for the horizontal axis x, from left to right forward; y-axis is vertical. From top to bottom forward
2.Qt GUI components in the upper left corner positioning
can be sized 3.Qt GUI components in the coordinate system

Guess you like

Origin blog.51cto.com/13475106/2427402