#include "maxpicshowform.h"
#include "ui_maxpicshowform.h"
#include <iostream>
#pragma execution_character_set("utf-8")//让能够正常显示中文字符串
MaxPicShowForm::MaxPicShowForm(QWidget *parent) :
QWidget(parent),
m_bMax(true),
m_bCtrlKeyPressed(false),
m_bClipPic(false),
m_bOriginalSize(false),
m_bFixWidthSize(false),
m_bFixHeightSize(false),
ui(new Ui::MaxPicShowForm),
m_Image(nullptr),
m_myGraphicRectItem(nullptr),
m_bStartSlider(false),
m_nFormIndex(0)
{
ui->setupUi(this);
m_qgraphicsScene = new myGraphicsScene;//要用QGraphicsView就必须要有QGraphicsScene搭配着用
QObject::connect(m_qgraphicsScene,&myGraphicsScene::keyPressEventSig,this,&MaxPicShowForm::getKeyPressEvent);//为了让本类接收子控件m_qgraphicsScene接收到的按键信号
mygraphicview = new myGraphicView(this);
mygraphicview->setObjectName(QString::fromUtf8("mygraphicview"));
mygraphicview->setGeometry(QRect(0, 0, 256, 192));
mygraphicview->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
mygraphicview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(mygraphicview->sizePolicy().hasHeightForWidth());
mygraphicview->setSizePolicy(sizePolicy);
mygraphicview->setBackgroundBrush(QBrush(QColor(240,240,240,255)));
QObject::connect(mygraphicview,&myGraphicView::DragDropFileLst,this,&MaxPicShowForm::getDragDropFileLst);//为了让本类接收子控件接收到的拖拽文件事件
//mygraphicview->setStyleSheet(QString::fromUtf8("border-image: url(:/image/debug_screenbg);"));//设置背景图
//上下左右的label,为了控制界面能够拖动拉伸
labelLft = new myLabel(this);
labelLft->setStyleSheet("QLabel {background-color: transparent;}");//设置背景透明
labelLft->raise();
labelLft->setScaleCursor(1);
connect(labelLft,&myLabel::moveEventSig,this,&MaxPicShowForm::getLeftScaleEvent);
labelRit = new myLabel(this);
labelRit->setStyleSheet("QLabel {background-color: transparent;}");//设置背景透明
labelRit->raise();
labelRit->setScaleCursor(1);//设置为左右拉升光标
connect(labelRit,&myLabel::moveEventSig,this,&MaxPicShowForm::getRightScaleEvent);
labelBot = new myLabel(this);
labelBot->setStyleSheet("QLabel {background-color: transparent;}");//设置背景透明
labelBot->raise();
labelBot->setScaleCursor(2);//设置为上下拉升光标
connect(labelBot,&myLabel::moveEventSig,this,&MaxPicShowForm::getBottomScaleEvent);
labelTop = new myLabel(this);
labelTop->setStyleSheet("QLabel {background-color: transparent;}");//设置背景透明
labelTop->setScaleCursor(2);//设置为上下拉升光标
connect(labelTop,&myLabel::moveEventSig,this,&MaxPicShowForm::getTopScaleEvent);
labelRB = new myLabel(this);
labelRB->setStyleSheet("QLabel {background-color: transparent;}");//设置背景透明
labelRB->setScaleCursor(3);//设置为右下拉升光标
connect(labelRB,&myLabel::moveEventSig,this,&MaxPicShowForm::getRBScaleEvent);
//没有图片时候的背景
labelScreenBack = new myLabel(this);
labelScreenBack->setStyleSheet(QString::fromUtf8("border-image: url(:/image/screenback);"));
labelScreenBack->setGeometry(0,0,this->width(),this->height());
//标题栏的label
labelTital = new myLabel(this);
labelTital->setText(" EditPic by Bruce");
labelTital->setGeometry(0,0,this->width(),30);
labelTital->setStyleSheet(QString::fromUtf8("border-image: url(:/image/titalback);"));
QPalette pa;
pa.setColor(QPalette::WindowText,Qt::white);
labelTital->setPalette(pa);
labelTital->setWindowFlags(Qt::WindowStaysOnTopHint);//置顶显示
labelTital->raise();
connect(labelTital,&myLabel::moveEventSig,this,&MaxPicShowForm::getMoveEvent);
connect(labelTital,&myLabel::mouseDoubleClickSig,this,&MaxPicShowForm::getMaxEvent);
labelclose = new myLabel(this);
labelclose->setStyleSheet(QString::fromUtf8("border-image: url(:/image/close);"));
labelclose->raise();
connect(labelclose,&myLabel::mouseReleasedSig,this,&MaxPicShowForm::getCloseEvent);
labelmax = new myLabel(this);
labelmax->setStyleSheet(QString::fromUtf8("border-image: url(:/image/max);"));
labelmax->raise();
connect(labelmax,&myLabel::mouseReleasedSig,this,&MaxPicShowForm::getMaxEvent);
labelpopMenu = new myLabel(this);
labelpopMenu->setStyleSheet(QString::fromUtf8("border-image: url(:/image/popMenu);"));
labelpopMenu->raise();
connect(labelpopMenu,&myLabel::mouseReleasedSig,this,&MaxPicShowForm::getShowpopMenuEvent);
labelOpenInTital = new myLabel(this);
labelOpenInTital->setStyleSheet(QString::fromUtf8("border-image: url(:/image/open0);"));
labelOpenInTital->raise();
connect(labelOpenInTital,&myLabel::mouseReleasedSig,this,&MaxPicShowForm::getOpenFileEvent);
labelmin = new myLabel(this);
labelmin->setStyleSheet(QString::fromUtf8("border-image: url(:/image/min);"));
labelmin->raise();
connect(labelmin,&myLabel::mouseReleasedSig,this,&MaxPicShowForm::getMinEvent);
labelTop->raise();
labelRB->raise();
//打开文件的labelOpenFile
labelOpenFile = new myLabel(this);
labelOpenFile->setStyleSheet(QString::fromUtf8("border-image: url(:/image/open);"));
labelOpenFile->setGeometry(this->width()/2-100,this->height()/2-40,200,80);
labelOpenFile->raise();
connect(labelOpenFile,&myLabel::mouseReleasedSig,this,&MaxPicShowForm::getOpenFileEvent);
//左右切换按钮
labelLeftArrow = new myLabel(this);
labelLeftArrow->setStyleSheet(QString::fromUtf8("border-image: url(:/image/leftArrow);"));
labelLeftArrow->setGeometry(0,0,0,0);
labelLeftArrow->raise();
connect(labelLeftArrow,&myLabel::mouseReleasedSig,this,&MaxPicShowForm::getLeftArrowEvent);
labelRightArrow = new myLabel(this);
labelRightArrow->setStyleSheet(QString::fromUtf8("border-image: url(:/image/rightArrow);"));
labelRightArrow->setGeometry(0,0,0,0);
labelRightArrow->raise();
connect(labelRightArrow,&myLabel::mouseReleasedSig,this,&MaxPicShowForm::getrightArrowEvent);
//创建菜单对象
pMenu = new QMenu(this);
QAction *pActionFitWnd = new QAction("适应窗口", pMenu);
QAction *pActionFitWidth = new QAction("适应宽度", pMenu);
QAction *pActionOriginSize = new QAction("原图大小", pMenu);
QAction *pActionMaxWnd = new QAction("界面最大化", pMenu);
//1:适应窗口 3:适应宽度 4:原始大小 5:界面最大化
pActionFitWnd->setData(1);
pActionFitWidth ->setData(3);
pActionOriginSize->setData(4);
pActionMaxWnd->setData(5);
//把QAction对象添加到菜单上
pMenu->addAction(pActionFitWnd);
pMenu->addAction(pActionFitWidth);
pMenu->addAction(pActionOriginSize);
pMenu->addAction(pActionMaxWnd);
//连接鼠标右键点击信号
connect(pActionFitWnd, SIGNAL(triggered()), this, SLOT(onMenuEvent()));
connect(pActionOriginSize, SIGNAL(triggered()), this, SLOT(onMenuEvent()));
connect(pActionFitWidth, SIGNAL(triggered()), SLOT(onMenuEvent()));
connect(pActionMaxWnd, SIGNAL(triggered()), this, SLOT(onMenuEvent()));
setAcceptDrops(true);
mygraphicview->setAcceptDrops(true);
}
MaxPicShowForm::~MaxPicShowForm()
{
delete labelTital;
delete labelmax;
delete labelpopMenu;
delete labelOpenInTital;
delete labelmin;
delete labelclose;
delete labelLft;
delete labelRit;
delete labelBot;
delete labelTop;
没有合适的资源?快使用搜索试试~ 我知道了~
qt编写的窗口多开图片显示器
共34个文件
png:13个
cpp:8个
h:7个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 164 浏览量
2023-11-20
17:04:38
上传
评论
收藏 1.14MB RAR 举报
温馨提示
本程序可打开多张图片的时候,自动为每一张图片打开新的窗口来显示图像,每个窗口都能拖动、缩放图片、并显示鼠标悬停位置的RGB像素值。如果是16位深的灰度图,则可以显示鼠标悬停位置实际的灰度值。 程序支持从文件夹将图片拖进本窗口并显示。 每个窗口支持自适应窗口显示、自适应宽度显示、按实际图片大小显示。
资源推荐
资源详情
资源评论
收起资源包目录
EditPic20231117MultiPicForm.rar (34个子文件)
EditPic
mygraphicview.cpp 3KB
maxpicshowform.cpp 31KB
mylabel.cpp 4KB
imagewidget.cpp 8KB
dialog.ui 708B
dialog.cpp 5KB
mygraphicsscene.h 882B
mygraphicsscene.cpp 820B
mygraphicview.h 1KB
res
screenback.png 28KB
debug_screenbg.jpg 19KB
rightArrow.png 22KB
screenbackStar.png 1MB
popMenu.png 19KB
frame.png 20KB
min.png 19KB
OpenFile.png 22KB
leftArrow.png 22KB
back.png 49KB
open.png 20KB
play.png 20KB
max.png 19KB
close.png 19KB
images.qrc 618B
main.cpp 353B
EditPic.pro 2KB
imagewidget.h 2KB
mylabel.h 1KB
mygraphicrectitem.cpp 6KB
mygraphicrectitem.h 2KB
maxpicshowform.h 5KB
dialog.h 1KB
Search.ico 56KB
maxpicshowform.ui 338B
共 34 条
- 1
资源评论
GreenHandBruce
- 粉丝: 393
- 资源: 51
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功