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

  • 相关阅读:
    scroll-behavior 让滚动更顺滑
    CSS3实现类似装订(缝纫)效果
    hadoop伪分布安装
    开始hadoop
    Boostrap 模态框 水平垂直居中问题
    ASP.NET MVC 下 引用阿里巴巴和IconFont字体路径404问题
    ajax 初始化请求前携带参数
    边框圆角方法
    DIV 清除样式浮动万能代码
    ASP.NET MVC 增强Convert用法+【分页2】
  • 原文地址:https://www.cnblogs.com/lxuechao/p/12672917.html
Copyright © 2011-2022 走看看