11.13号作业

#include "mywidget.h"

MyWidget::MyWidget(QWidget *parent)
    : QWidget(parent)
{
    this->setWindowTitle("英雄联盟");
    this->resize(862,486);
    this->setFixedSize(862,486);
    this->setWindowFlag(Qt::FramelessWindowHint);
    this->setStyleSheet("background-color:rgb(80,110,115)");
    QLabel *lab1=new QLabel(this);
    lab1->resize(640,486);
    QMovie *mv=new QMovie("D:\\23081C++\\pictrue\\pictrue\\1.gif");
    lab1->setMovie(mv);
    mv->start();
    lab1->setScaledContents(true);
    QLabel *lab2=new QLabel(this);
    lab2->resize(50,50);
    lab2->setPixmap(QPixmap("D:\\23081C++\\pictrue\\pictrue\\22.png"));
    lab2->move(20,20);
    lab2->setScaledContents(true);
    QLabel * lab3=new QLabel(this);
    lab3->resize(222,150);
    lab3->setPixmap(QPixmap("D:\\23081C++\\pictrue\\pictrue\\2.png"));
    lab3->move(640,0);
    QLabel * lab4=new QLabel(this);
    lab4->resize(20,20);
    lab4->setPixmap(QPixmap("D:\\23081C++\\pictrue\\pictrue\\userName.jpg"));
    lab4->move(680,300);
    lab4->setScaledContents(true);
    QLabel * lab5=new QLabel(this);
    lab5->resize(20,20);
    lab5->setPixmap(QPixmap("D:\\23081C++\\pictrue\\pictrue\\passwd.jpg"));
    lab5->move(680,330);
    lab5->setScaledContents(true);
    QLineEdit *edit1=new QLineEdit(this);
    edit1->move(700,300);
    edit1->setPlaceholderText("账号");
    QLineEdit *edit2=new QLineEdit(this);
    edit2->move(700,330);
    edit2->setPlaceholderText("密码");
    edit2->setEchoMode(QLineEdit::Password);
    QPushButton * btn1=new QPushButton(this);
    btn1->resize(155,30);
    btn1->move(680,360);
    btn1->setText("登录");
    btn1->setStyleSheet("background-color:orange;border-radius:10px");
    QPushButton * btn2=new QPushButton(this);
    btn2->resize(20,20);
    btn2->move(842,0);
    btn2->setText("x");
    QPushButton * btn4=new QPushButton(this);
    btn4->resize(20,20);
    btn4->move(822,0);
    btn4->setText("□");

    QPushButton * btn3=new QPushButton(this);
    btn3->resize(20,20);
    btn3->move(802,0);
    btn3->setText("-");

    // 创建一个QLabel对象
    QLabel *label = new QLabel(this);
    label->setFixedSize(60, 60);
    // 加载图片并调整尺寸
    QPixmap pixmap("D:\\23081C++\\pictrue\\pictrue\\3.png");
    pixmap = pixmap.scaled(label->size(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
    // 创建圆形mask,使用QPainter绘制
    QPixmap roundPixmap(label->size());
    roundPixmap.fill(Qt::transparent);
    QPainter painter(&roundPixmap);
    painter.setRenderHint(QPainter::Antialiasing, true);
    painter.setPen(Qt::NoPen);
    painter.setBrush(Qt::white);
    painter.drawEllipse(roundPixmap.rect());
    // 将原始图片按照mask绘制到圆形pixmap上
    painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
    painter.drawPixmap(0, 0, pixmap);
    // 将圆形pixmap设置为label的背景图像
    label->setPixmap(roundPixmap);
    label->move(720,200);
    lab3->setScaledContents(true);
}
MyWidget::~MyWidget()
{
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值