资源简介
基于Qt QGraphicsScene的画图演示,可对图元进行移动和缩放,例子比较简单,可以参考。

代码片段和文件信息
#include “eresizefocus.h“
#include “svgscene.h“
#include “SvgGraphicsItem.h“
#include
EResizeFocus::EResizeFocus(PosInHost posSvgGraphicsItem *svgitem)
: QGraphicsRectItem(0066)posInHost(pos)wsize(6)
{
/*SvgScene::myscene->addItem(this);
setAcceptsHoverEvents(true);
setVisible(false);
QPen pen = QPen(QColor(Qt::blue));
setPen(pen);
QBrush brush = QBrush(QColor(Qt::red));
setBrush(brush);*/
mySvgItem = svgitem;
initial();
//locateInHost();
}
EResizeFocus::~EResizeFocus()
{
}
void EResizeFocus::initial(){
SvgScene::myscene->addItem(this);
setAcceptsHoverEvents(true);
setVisible(false);
QPen pen = QPen(QColor(Qt::blue));
setPen(pen);
QBrush brush = QBrush(QColor(Qt::red));
setBrush(brush);
locateInHost();
}
void EResizeFocus::hoverEnterEvent ( QGraphicsSceneHoverEvent * event )
{
switch(posInHost){
case NORTH_MIDDLE:
setCursor(Qt::SizeVerCursor);
break;
case SOUTH_MIDDLE:
setCursor(Qt::SizeVerCursor);
break;
case EAST_MIDDLE:
setCursor(Qt::SizeHorCursor);
break;
case WEST_MIDDLE:
setCursor(Qt::SizeHorCursor);
break;
case NORTH_WEST:
setCursor(Qt::SizeFDiagCursor);
break;
case SOUTH_EAST:
setCursor(Qt::SizeFDiagCursor);
break;
case NORTH_EAST:
setCursor(Qt::SizeBDiagCursor);
break;
case SOUTH_WEST:
setCursor(Qt::SizeBDiagCursor);
break;
default:
break;
}
QGraphicsRectItem::hoverEnterEvent(event);
}
void EResizeFocus::hoverLeaveEvent ( QGraphicsSceneHoverEvent * event )
{
QGraphicsRectItem::hoverLeaveEvent(event);
}
void EResizeFocus::locateInHost()
{
const QRectF parentRect = mySvgItem->matrixBoundingRect();
qreal x = 0 y = 0;
switch(posInHost){
case NORTH_MIDDLE:
x = parentRect.x() + parentRect.width() / 2 - wsize / 2;
y = parentRect.y()- wsize / 2;
break;
case SOUTH_MIDDLE:
x = parentRect.x() + parentRect.width() / 2 - wsize / 2;
y = parentRect.y() +parentRect.height() - wsize/2;
break;
case EAST_MIDDLE:
x = parentRect.x() + parentRect.width() - wsize/2;
y = parentRect.y() + parentRect.height() / 2 - wsize / 2;
break;
case WEST_MIDDLE:
x = parentRect.x()- wsize / 2;
y = parentRect.y()+ parentRect.height() / 2 - wsize / 2;
break;
case NORTH_WEST:
x = parentRect.x()- wsize / 2;
y = parentRect.y()- wsize / 2;
break;
case SOUTH_EAST:
x = parentRect.x() + parentRect.width() - wsize/2;
y = parentRect.y() + parentRect.height() - wsize/2;
break;
case NORTH_EAST:
x = parentRect.x() + parentRect.width() - wsize/2;
y = parentRect.y()- wsize / 2;
break;
case SOUTH_WEST:
x = parentRect.x()- wsize / 2;
y = parentRect.y() + parentRect.height() - wsize/2;
break;
default:
break;
}
setPos(xy);
}
const EResizeFocus &EResizeFocus::operator=(const EResizeFocus & right )
{
wsize = right.wsize;
return *this;
}
void
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 131072 2010-11-10 15:54 画图调节大小源代码\Debug\MainWindowTest.exe
文件 1320224 2010-11-10 15:54 画图调节大小源代码\Debug\MainWindowTest.ilk
文件 2427904 2010-11-10 15:54 画图调节大小源代码\Debug\MainWindowTest.pdb
文件 15614 2010-11-10 15:54 画图调节大小源代码\MainWindowTest\Debug\BuildLog.htm
文件 157118 2010-11-10 15:54 画图调节大小源代码\MainWindowTest\Debug\eresizefocus.obj
文件 42798 2010-11-10 15:54 画图调节大小源代码\MainWindowTest\Debug\main.obj
文件 621 2010-11-10 15:54 画图调节大小源代码\MainWindowTest\Debug\MainWindowTest.exe.intermediate.manifest
文件 185737 2010-11-10 15:54 画图调节大小源代码\MainWindowTest\Debug\mainwindowtest.obj
文件 44236 2010-11-10 15:54 画图调节大小源代码\MainWindowTest\Debug\moc_mainwindowtest.obj
文件 49908 2010-11-10 15:54 画图调节大小源代码\MainWindowTest\Debug\moc_myitemproxywidget.obj
文件 67 2010-11-10 15:54 画图调节大小源代码\MainWindowTest\Debug\mt.dep
文件 168409 2010-11-10 15:54 画图调节大小源代码\MainWindowTest\Debug\myitemproxywidget.obj
文件 23085 2010-11-10 15:54 画图调节大小源代码\MainWindowTest\Debug\qrc_mainwindowtest.obj
文件 156947 2010-11-10 15:54 画图调节大小源代码\MainWindowTest\Debug\svgellipseitem.obj
文件 70227 2010-11-10 15:54 画图调节大小源代码\MainWindowTest\Debug\svggraphicsitem.obj
文件 156517 2010-11-10 15:54 画图调节大小源代码\MainWindowTest\Debug\svgrectitem.obj
文件 138823 2010-11-10 15:54 画图调节大小源代码\MainWindowTest\Debug\svgscene.obj
文件 133002 2010-11-10 15:54 画图调节大小源代码\MainWindowTest\Debug\svgview.obj
文件 1977344 2010-11-10 15:54 画图调节大小源代码\MainWindowTest\Debug\vc90.idb
文件 1757184 2010-11-10 15:54 画图调节大小源代码\MainWindowTest\Debug\vc90.pdb
文件 5891 2009-12-30 08:39 画图调节大小源代码\MainWindowTest\eresizefocus.cpp
文件 1258 2009-12-29 21:13 画图调节大小源代码\MainWindowTest\eresizefocus.h
文件 2462 2010-11-10 15:54 画图调节大小源代码\MainWindowTest\GeneratedFiles\Debug\moc_mainwindowtest.cpp
文件 2405 2010-11-10 15:54 画图调节大小源代码\MainWindowTest\GeneratedFiles\Debug\moc_myitemproxywidget.cpp
文件 72423 2010-11-10 15:54 画图调节大小源代码\MainWindowTest\GeneratedFiles\qrc_mainwindowtest.cpp
文件 4347 2009-09-12 11:25 画图调节大小源代码\MainWindowTest\GeneratedFiles\ui_mainwindowtest.h
文件 1352 2009-07-14 08:13 画图调节大小源代码\MainWindowTest\GeneratedFiles\ui_table.h
文件 1339 2008-01-09 08:43 画图调节大小源代码\MainWindowTest\images\copy.png
文件 1323 2008-01-09 08:43 画图调节大小源代码\MainWindowTest\images\cut.png
文件 2011 2008-01-09 08:43 画图调节大小源代码\MainWindowTest\images\find.png
............此处省略51个文件信息
相关资源
- 酒店管理系统基于Qt Creator5)
- vtk QT做的三维地质可视化系统2of2
- Qt局域网聊天软件
- Qt Creator opengl实现四元数鼠标控制轨迹
- QT局域网聊天系统(基于QT5.修改过)
- qt-电子点菜系统
- C 餐厅叫号系统(QT平)
- QT 实现文件下载
- qt图像处理
- 画图程序MFC/VC/VC CRectTracker 串行化
- QT,JPEG解码源代码(已完成)
- 用MFC实现简单的画图功能
- VC 6.0 MFC做画图软件
- Qt 播放音频文件
- Qt 读取16进制的data文件
- MQTT+串口(usart)透传
- 易语言QQTEA算法源码
- VC工程转Qt工程文件的工具
- MQTT推送Demo
- Scrach 画图.sb
- 基于Linux、QT的视频监控系统的设计与
- Qt 百度地图 定位
- QT酷炫界面开发指南《QmlBook》
- raphael画各种简单的图形都可以拖动
- Ubuntu下操作Excel,qt代码
- Qt图片浏览器 --基于Qt的Graphics View f
- qtnribbon2破解
- Qt软件开发 完整项目代码
- delphi 画图撤销控件
- fastlib——十分好用的画图工具
评论
共有 条评论