#include "widget.h"
#include "QGridLayout"
#include "QButtonGroup"
#include <QMouseEvent>
#include <QApplication>
#include "QMessageBox"
#include "QDebug"
//void MyLabel::enterEvent(QMouseEvent *ev)
//{
// int mouse_x = QCursor::pos().x();//鼠标点击处横坐标
// int mouse_y = QCursor::pos().y();//鼠标点击处纵坐标
// QWidget *action = QApplication::widgetAt(mouse_x, mouse_y);//获取鼠标点击处的控件
//}
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
init_ui();
}
Widget::~Widget()
{
}
void Widget::init_ui()
{
// this->setStyleSheet("QRadioButton::indicator {width: 0px;height: 0px;}");
this->setStyleSheet("QRadioButton::indicator:unchecked:hover {width: 260px;height: 260px;};QRadioButton::indicator {width: 0px;height: 0px;}");
QPalette palette;
//设置主窗口背景颜色
palette.setColor(QPalette::Window,QColor(28,28,28));
this->setPalette(palette);
//resize(1920,1080);
setMaximumSize(1920,1080); // Qt设置最大尺寸函数
setMinimumSize(1920,1080); // Qt设置最小尺寸函数
lable_log = new QLabel("",this);
lable_log->move(20,10);
lable_log->resize(QSize(150,40));
QPixmap outPixmap_log = QPixmap();
//pixmap加载照片
outPixmap_log.load(":/new/img_resource/img/log1.png");
//显示到label_pic、保持缩放比例
outPixmap_log.scaled(lable_log->size(), Qt::KeepAspectRatio);
//设置照片缩放后 填满label_pic
lable_log->setScaledContents(true);
lable_log->setPixmap(outPixmap_log);
lable_img1 = new QLabel("",this);
lable_img1->move(220,0);
lable_img1->resize(QSize(5,60));
lable_img1->setStyleSheet("background-image: url(:/new/img_resource/img/top-bg-2.844eaca4.png);background-repeat:no-repeat");
QLabel *lable_hz = new QLabel("<h2><i></i><font color=red>频率范围 </font><font color=white>30MHz-6GHz</font></h2>",this);
lable_hz->move(270,20);
lable_log2 = new QLabel("",this);
lable_log2->move(1200,10);
lable_log2->resize(QSize(150,40));
QPixmap outPixmap_log2 = QPixmap();
//pixmap加载照片
outPixmap_log2.load(":/new/img_resource/img/log1.png");
//显示到label_pic、保持缩放比例
outPixmap_log2.scaled(lable_log2->size(), Qt::KeepAspectRatio);
//设置照片缩放后 填满label_pic
lable_log2->setScaledContents(true);
lable_log2->setPixmap(outPixmap_log2);
lable_img2 = new QLabel("",this);
lable_img2->move(1400,0);
lable_img2->resize(QSize(5,60));
lable_img2->setStyleSheet("background-image: url(:/new/img_resource/img/top-bg-2.844eaca4.png);background-repeat:no-repeat");
QLabel *lable_hz2 = new QLabel("<h2><i></i><font color=red>频率范围 </font><font color=white>30MHz-6GHz</font></h2>",this);
lable_hz2->move(1470,20);
//设置设备
location(100,100);
}
void Widget::location(int x, int y)
{
block1=new QButtonGroup(this);
connect(block1, SIGNAL(idClicked(int)), this, SLOT(whick_clicked(int)));
//分组
rb1 = new QRadioButton("", this);
rb1->move(x,y);
rb1->resize(QSize(260,260));
//rb1->setStyleSheet("QRadioButton{image: url(:/new/img_resource/img/BYSY-27100RSA-1-2.dc1207b4.png);spacing: 2px;color: white;background-origin:content;background-position:content;border-width: 0px;border-style: solid;border-color: rgb(85, 255, 255); font: bold 13px; color:rgb(173,210,228);width: 250px;height: 250px; }QRadioButton::indicator { width: 0px;height: 0px;}");
rb1->setStyleSheet("image: url(:/new/img_resource/img/BYSY-27100RSA-1-2.dc1207b4.png);spacing: 2px;color: white;background-origin:content;background-position:content;border-width: 0px;border-style: solid;border-color: rgb(85, 255, 255); font: bold 13px; color:rgb(173,210,228);width: 250px;height: 250px;QRadioButton::indicator { width: 0px;height: 0px;}");
block1->addButton(rb1,1);
rb2 = new QRadioButton("", this);
rb2->move(300+x,y);
rb2->resize(QSize(250,250));
rb2->setStyleSheet("QRadioButton{image: url(:/new/img_resource/img/BYSY-S200B-2.c4b44311.png);width: 250px;height: 250px;}QRadioButton::indicator { width: 0px;height: 0px;}");
block1->addButton(rb2,2);
rb3 = new QRadioButton("", this);
rb3->move(600+x,y);
rb3->resize(QSize(250,250));
rb3->setStyleSheet("QRadioButton{image: url(:/new/img_resource/img/BYSY-27100RSA-2.ca56efa3.png);width: 250px;height: 250px;}QRadioButton::indicator { width: 0px;height: 0px;}");
block1->addButton(rb3,3);
rb4 = new QRadioButton("", this);
rb4->move(x,y+300);
rb4->resize(QSize(250,250));
rb4->setStyleSheet("QRadioButton{image: url(:/new/img_resource/img/BYSY-27100RSA-3.6c691b27.png);width: 250px;height: 250px;}QRadioButton::indicator { width: 0px;height: 0px;}");
block1->addButton(rb4,4);
rb5 = new QRadioButton("", this);
rb5->move(300+x,y+300);
rb5->resize(QSize(250,250));
rb5->setStyleSheet("QRadioButton{image: url(:/new/img_resource/img/MS2720T-2.a8d24ec2.png);width: 250px;height: 250px;}QRadioButton::indicator { width: 0px;height: 0px;}");
block1->addButton(rb5,5);
rb6 = new QRadioButton("", this);
rb6->move(600+x,y+300);
rb6->resize(QSize(250,250));
rb6->setStyleSheet("QRadioButton{image: url(:/new/img_resource/img/MS2090A-2.a7e6c37d.png);width: 250px;height: 250px;}QRadioButton::indicator { width: 0px;height: 0px;}");
block1->addButton(rb6,6);
}
void Widget::whick_clicked(int num)
{
QString string_temp = QString::number(num,10);
QMessageBox box;
//设置文本框的大小
box.setStyleSheet("QLabel{"
"min-width:100px;"
"min-height:40px; "
"font-size:16px;"
"}");
box.setText("设备: "+string_temp);
box.setWindowTitle("设备");
box.setIcon(QMessageBox::Icon::Warning );
//box.setButtonText(QMessageBox::Ok , QString::fromLocal8Bit("确定"));
box.setButtonText(QMessageBox::Ok , "确定");
box.exec();
}
/*
void Widget::location(int x, int y)
{
rb1 = new MyLabel();
rb1->setParent(this);
rb1->setStyleSheet("QLabel:hover{height:265px;width:265px;}");
rb1->move(x,y);
rb1->resize(QSize(250,250));
QPixmap outPixmap = QPixmap();
//pixmap加载照片
outPixmap.load(":/new/img_resource/img/BYSY-27100RSA-1-2.dc1207b4.png");
//显示到label_pic、保持缩放比例
outPixmap.scaled(rb1->size(), Qt::KeepAspectRatio);
//设置照片缩放后 填满label_pic
rb1->setScaledContents(true);
rb1->setPixmap(outPixmap);
pic2 = new MyLabel();
pic2->setParent(this);
pic2->setStyleSheet("QLabel:hover{height:265px;width:265px;}");
pic2->move(300+x,y);
pic2->resize(QSize(250,250));
QPixmap outPixmap1 = QPixmap();
//pixmap加载照片
outPixmap1.load(":/new/img_resource/img/BYSY-S200B-2.c4b44311.png");
//显示到label_pic、保持缩放比例
outPixmap1.scaled(pic2->size(), Qt::KeepAspectRatio);
//设置照片缩放后 填满label_pic
pic2->setScaledContents(true);
pic2->setPixmap(outPixmap1);
pic3 = new MyLabel();
pic3->setParent(this);
pic3->setStyleSheet("QLabel:hover{height:265px;width:265px;}");
pic3->move(600+x,y);
pic3->resize(QSize(250,250));
QPixmap outPixmap2 = QPixmap();
//pixmap加载照片
outPixmap2.load(":/new/img_resource/img/BYSY-27100RSA-2.ca56efa3.png");
//显示到label_pic、保持缩放比例
outPixmap2.scaled(pic3->size(), Qt::KeepAspectRatio);
//设置照片缩放后 填满label_pic
pic3->setScaledContents(true);
pic3->setPixmap(outPixmap2);
pic4 = new MyLabel();
pic4->setParent(this);
pic4->setStyleSheet("QLabel:hover{height:265px;width:265px;}")
没有合适的资源?快使用搜索试试~ 我知道了~
Qt 单选按钮 QButtonGroup 设置背景图片以及去掉小圆点
共37个文件
png:25个
css:3个
cpp:2个
需积分: 0 6 下载量 186 浏览量
2023-01-10
15:52:50
上传
评论
收藏 3.94MB RAR 举报
温馨提示
Qt QButtonGroup 单选按钮、背景、Qss
资源推荐
资源详情
资源评论
收起资源包目录
test1.rar (37个子文件)
test1
test1.pro.user 33KB
widget.cpp 9KB
test1.pro.user.01ce7b8 32KB
Resource.qrc 2KB
main.cpp 576B
img
ICS-06.a79cd380.png 13KB
BYSY-27100RSA-3-2.e63a5384.png 61KB
cen-background.6b675a4b.png 534KB
sw-left-2.7442615a.png 8KB
BYSY-S200B-2.c4b44311.png 93KB
BYSY-27100RSA-2.ca56efa3.png 454KB
ICS-02.fab33ed5.png 11KB
top-bg-2.844eaca4.png 34KB
ICS-07.702c68ba.png 8KB
BYSY-27100RSA-1-2.dc1207b4.png 732KB
ICS-05.1edc049f.png 12KB
ICS-03.9c719ae1.png 10KB
bottom-bg.645f0484.png 26KB
log.png 2KB
MS2090A.d01e22b5.gif 334KB
log1.png 5KB
BYSY-27100RSA-3.6c691b27.png 64KB
ICS-01.39ddfbc6.png 11KB
BYSY-27100RSA.1b7dd86c.png 751KB
MS2720T-2.a8d24ec2.png 61KB
MS2720T.9728b51e.gif 109KB
ICS-04.e2e884fc.png 10KB
BYSY-27100RSA-2-2.eef6997a.png 500KB
sw-left-1.cb20d8a6.png 28KB
content.1cb6bd61.png 13KB
MS2090A-2.a7e6c37d.png 51KB
BYSY-S200B.79435b67.png 102KB
css
app.d7e9b2c4.css 4KB
chunk-vendors.8de084b5.css 210KB
app.14bdd4e5.css 4KB
test1.pro 609B
widget.h 1KB
共 37 条
- 1
资源评论
鼎鼎_home
- 粉丝: 15
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于串口通信的光通信上位机,包括运动控制和通信协议
- 串口与以太网文件传送协议(或自定义控制协议)
- Qt开发windows系统安装教程与代码实例.txt
- QT6实现的附带文件传输协议的串口终端
- 一个串口通讯类和调用Demo 通过设置串口、设置串口自定义协议,可方便对串口发送数据与接收数据
- 华为OD模拟题及参考答案.仅供学习和模拟考试使用
- stm32f103c8t6基于modbus协议和使用串口读取温湿度
- 英雄联盟LOL金克斯4K电脑壁纸
- Microbrain道闸产品上位机,以MahApps库为基础搭建界面,集成了串口(UART)、CAN、WIFI通信,十六进制协议
- Android串口通讯, 支持发送数据回调, 支持并发处理, 自定义协议, CRC校验, 自动粘包, 自动去除冗余的干扰数据
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功