zoukankan      html  css  js  c++  java
  • QT如何设置窗口背景图片拉伸填充窗口?

    QT如何设置窗口背景图片拉伸填充窗口?

    以下内容引用自:百度知道:网址中frostweek的回答:{
    1,创建QPixmap指针;

    QPixmap *pixmapBackground;

    pixmapBackground=new QPixmap(":/skin/myPicture.png");

    2,定义paintEvent()函数;
    3,在paintEvent()函数中,调用drawPixmap()。

    painter.drawPixmap(100,50,400,300,*pixmapBackground);

    前两个参是图片的左上角x、y坐标;后两个参就是你要设定的图片缩放尺寸了。}
    但是这是一个固定大小的窗口:不能随窗口缩放
    若想跟随窗口缩放我们需要知道窗口大小:

    获取窗口位置和大小

    以下内容引用自:努力减肥的小胖子5的个人博客:网址

    //窗口左上角的位置(含边框)
    qDebug() << this->frameGeometry().x() << this->frameGeometry().y() << ;//1
    qDebug() << this->x() << this->y();//2
    qDebug() << this->pos().x() << this->pos().y();//3
    //窗口的宽度和高度(含边框)
    qDebug() << this->frameGeometry().width() << this->frameGeometry().height();
    //窗口左上角的位置(不含边框)
    qDebug() << this->geometry().x() << this->geometry().y();
    //窗口的宽度和高度(不含边框)
    qDebug() << this->geometry().width() << this->geometry().height();//1
    qDebug() << this->width() << this->height();//2
    qDebug() << this->rect().width() << this->rect().height();//3
    qDebug() << this->size().width() << this->size().height();//4

  • 相关阅读:
    Python模拟浏览器前进后退操作
    Python之sort()函数详解
    Python之抓取网页元素
    Python之列表与元组的区别详解
    Python3之正则表达式详解
    Python解析JSON详解
    Python3之文件读写操作详解
    Python之import方法引入模块详解
    2015年12月英语四级写作模板
    裸考大学英语四级写作核心词汇及模板
  • 原文地址:https://www.cnblogs.com/lxuechao/p/12672917.html
Copyright © 2011-2022 走看看