ToB企服应用市场:ToB评测及商务社交产业平台

标题: 【鸣潮,原神PC端启动器】仿二次元手游PC端游戏启动器,以鸣潮为例。 [打印本页]

作者: 星球的眼睛    时间: 2024-11-15 14:52
标题: 【鸣潮,原神PC端启动器】仿二次元手游PC端游戏启动器,以鸣潮为例。
二游GAMELauncher启动器

1.前言

2. 划分模块

3. 主体窗口

4. 顶部标题栏

5. 公告栏

6. 轮播图

7. 下载模块

8. 设置

<ul>设置界面比较贫苦,里面的QCheckBox和QRadioButton的结果无法通过QSS实现,需要重写,里面的漏斗形图形需要比较多步骤去绘制。
重写QRadioButton
  1.   void paintEvent(QPaintEvent* event) override
  2.     {
  3.           QPainter painter(this);
  4.           painter.setRenderHint(QPainter::Antialiasing);
  5.           QStyleOptionButton option;
  6.           initStyleOption(&option);
  7.           painter.save();
  8.   
  9.   
  10.   
  11.           // 获取单选框的矩形区域
  12.           QRect radioButtonRect = style()->subElementRect(QStyle::SE_RadioButtonIndicator, &option, this);
  13.   
  14.           // 增大单选框的尺寸
  15.           int enlargedSize = 24;  // 自定义单选框的大小(增大后的大小)
  16.           radioButtonRect.setWidth(enlargedSize);
  17.           radioButtonRect.setHeight(enlargedSize);
  18.   
  19.   
  20.   
  21.           painter.setBrush(Qt::NoBrush);  // 不填充背景
  22.           painter.setPen(QPen(QColor("#8C8C8C"), 2));  // 使用灰色边框,线宽为2
  23.   
  24.           // 绘制增大的圆形的单选框
  25.           QRect circleRect = radioButtonRect.adjusted(2, 2, -2, -2); // 调整绘制圆形的位置
  26.           painter.drawEllipse(circleRect);
  27.   
  28.           // 如果当前单选框被选中,则填充中心
  29.           if (isChecked())
  30.           {   
  31.   
  32.               painter.setPen(QPen(QColor("#BB9F5E"), 2));
  33.               painter.drawEllipse(circleRect);
  34.   
  35.   
  36.               painter.setBrush(QColor("#BB9F5E"));   // 设置选中时的填充颜色为白色
  37.               painter.drawEllipse(circleRect.adjusted(5,5, -5, -5));  // 绘制小圆圈,表示选中
  38.           }
  39.   
  40.           // 绘制文本,确保文本位置对齐
  41.           QRect textRect = option.rect;
  42.   
  43.           // 将文本左移,使其与增大的单选框右边对齐
  44.           textRect.setLeft(radioButtonRect.right() + 5);  // 将文本移到单选框右侧
  45.   
  46.           // 使文本垂直居中
  47.           textRect.moveTop(radioButtonRect.top() + (radioButtonRect.height() - textRect.height()) / 2);
  48.           painter.restore();
  49.   
  50.           // 使用默认的文本颜色(由样式表和控件状态决定)
  51.           style()->drawItemText(&painter, textRect, Qt::AlignVCenter, option.palette, isEnabled(), option.text);
  52.       }
复制代码
绘制设置框的线条和图形。
[code]void Setting::paintEvent(QPaintEvent*event){         QPainter p(this);      QPen pen;      QPainterPath path;      pen.setColor(QColor("#CFCFCF"));//CFCFCF      pen.setWidth(2);      p.setPen(pen);        //画顶部线条      int x = ui->labelSetting->pos().x();      int y = ui->labelSetting->pos().y()+ui->labelSetting->height()+10;      p.drawLine(x,y,x+this->width()-40,y);              //画圆弧      int aw = 20;      int endx = x+this->width()-35;      int endy = y;        int cx = endx-aw;      int cy = endy-aw;        int tx = cx-aw;      int ty = cy-aw;        //int bx = cx+aw;      int by = cy+aw;          int startAngle = 270;      int spanAngle = 80;      double rr = aw;        int cx1 = tx+aw;      int cy1 = ty+aw;      double ex1 = cx1 + rr * cos((startAngle + spanAngle) * 3.14 / 180);      double ey1 = cy1 - rr * sin((startAngle + spanAngle) * 3.14 / 180);        startAngle = 90;      spanAngle  = -80;      int cx2 = tx+aw;      int cy2 = by+aw;      double ex2 = cx2 + rr * cos((startAngle + spanAngle) * 3.14 / 180);      double ey2 = cy2 - rr * sin((startAngle + spanAngle) * 3.14 / 180);            p.setBrush(QColor("#333333"));      p.setPen(Qt::white);      path.moveTo(cx,by);      path.lineTo(ex1,ey1);      path.lineTo(ex2,ey2);      path.lineTo(cx,by);      p.drawPath(path);            path.clear();      path.moveTo(cx,by);      QRect r (tx,ty,aw*2,aw*2);  //x,y,width,height      QRect r2(tx,by,aw*2,aw*2);        pen.setWidth(1);      p.setPen(pen);      p.setRenderHint(QPainter::Antialiasing);      path.arcTo(r,270,80);      path.moveTo(cx,by);      path.arcTo(r2,90,-80);      p.fillPath(path,Qt::white);            //画顶部线条      pen.setColor(QColor("#464646"));      pen.setWidth(2);      p.setPen(pen);      p.drawLine(x+this->width()-35,0,x+this->width()-35,this->height());          //画右边线条      int s1x = ui->btnCancel->pos().x();      int s1y = ui->btnCancel->pos().y()-20;      int s2x = ui->btnOk->pos().x()+ui->btnOk->width();        pen.setColor(QColor("#CBCBCB"));      pen.setWidthF(1.5);      p.setPen(pen);      p.drawLine(s1x,s1y,s2x,s1y);          //画右下角三角形      QPoint p1(x+this->width()-35,this->height()-10);      QPoint p2(x+this->width()-35,this->height());      QPoint p3(x+this->width()-45,this->height());          QPolygon cons;      cons




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4