码迷,mamicode.com
首页 > 其他好文 > 详细

(二)widget部件的几何布局

时间:2016-07-19 22:02:16      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:

空的Qt项目    main.cpp代码:

#include<QApplication>
#include<QWidget>
#include<QDebug>

int main(int argc,char *argv[]){
    QApplication a(argc,argv);

    QWidget widget;
    widget.resize(400,300); //设置窗口大小
    widget.move(200,100);   //设置窗口位置
    widget.show();

    int x = widget.x();     //调试输出x的值
    qDebug("x:%d",x);
    int y = widget.y();
    qDebug("y:%d",y);
    QRect geometry = widget.geometry();
    QRect frame = widget.frameGeometry();
    qDebug()<<"geometry:"<<geometry<<"frame:"<<frame;

    return a.exec();
}

 

包含框架: x()   y()   frameGeometry()   pos()   move()

  xy为部件坐标,framegeometry为框架矩形值QRect类型,pos为在父窗口的位置,move为移动在父窗口里的位置

不包含框架:geometry()   width()   height()   rect()   size()

  geometry为部件矩形值QRect类型,width宽,heigeht高

调试输出: qDebug()    

(二)widget部件的几何布局

标签:

原文地址:http://www.cnblogs.com/ZQHS/p/5686386.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!