qt窗口坐标
新建一个mainwindow的工程,运行。
窗口的坐标:
代码:
1 //窗口左上角的位置(含边框) 2 qDebug() << "1(含边框):" << this->frameGeometry().x() << this->frameGeometry().y();//1 3 qDebug() << "2(含边框):" << this->x() << this->y();//2 4 qDebug() << "3(含边框):" << this->pos().x() << this->pos().y();//3 5 //窗口的宽度和高度(含边框) 6 qDebug() << "4(不含边框):" << this->frameGeometry().width() << this->frameGeometry().height(); 7 //窗口左上角的位置(不含边框) 8 qDebug() << "5(不含边框):" << this->geometry().x() << this->geometry().y(); 9 //窗口的宽度和高度(不含边框) 10 qDebug() << "6(不含边框):" << this->geometry().width() << this->geometry().height();//1 11 qDebug() << "7(不含边框):" << this->width() << this->height();//2 12 qDebug() << "8(不含边框):" << this->rect().width() << this->rect().height();//3 13 qDebug() << "9(不含边框):" << this->size().width() << this->size().height();//4
输出:
1(含边框): 989 578 2(含边框): 989 578 3(含边框): 989 578 4(不含边框): 902 519 5(不含边框): 1002 636 6(不含边框): 876 448 7(不含边框): 876 448 8(不含边框): 876 448 9(不含边框): 876 448