资源简介
基于QT QGraphicsView Framework的绘图软件,可以绘制常见的直线、矩形、圆、椭圆等图形,可以实现图形的交互如碰撞检测、控制手柄拖动缩放、撤销重做等。还有属性树的用法

代码片段和文件信息
#include “commands.h“
#include
MoveShapeCommand::MoveShapeCommand(QGraphicsScene *graphicsScene const QPointF &delta QUndoCommand *parent)
: QUndoCommand(parent)
{
myItem = 0;
myItems = graphicsScene->selectedItems();
myGraphicsScene = graphicsScene;
myDelta = delta;
bMoved = true;
}
MoveShapeCommand::MoveShapeCommand(QGraphicsItem * item const QPointF &delta QUndoCommand *parent)
: QUndoCommand(parent)
{
myGraphicsScene = 0;
myItem = item;
myDelta = delta;
bMoved = true;
}
//! [2]
void MoveShapeCommand::undo()
{
if ( myItem )
myItem->moveBy(-myDelta.x()-myDelta.y());
else if( myItems.count() > 0 ){
foreach (QGraphicsItem *item myItems) {
item->moveBy(-myDelta.x()-myDelta.y());
}
}
setText(Qobject::tr(“Undo Move %1%2“)
.arg(-myDelta.x()).arg(-myDelta.y()));
bMoved = false;
}
//! [2]
//! [3]
void MoveShapeCommand::redo()
{
if ( !bMoved ){
if ( myItem ){
myItem->moveBy(myDelta.x()myDelta.y());
myItem->scene()->update();
}else if( myItems.count() > 0 ){
foreach (QGraphicsItem *item myItems) {
item->moveBy(myDelta.x()myDelta.y());
}
myGraphicsScene->update();
}
}
setText(Qobject::tr(“Redo Move %1%2“)
.arg(myDelta.x()).arg(myDelta.y()));
}
//! [3]
//! [4]
RemoveShapeCommand::RemoveShapeCommand(QGraphicsScene *scene QUndoCommand *parent)
: QUndoCommand(parent)
{
myGraphicsScene = scene;
items = myGraphicsScene->selectedItems();
}
RemoveShapeCommand::~RemoveShapeCommand()
{
}
//! [4]
//! [5]
void RemoveShapeCommand::undo()
{
foreach (QGraphicsItem *item items) {
QGraphicsItemGroup *g = dynamic_cast(item->parentItem());
if ( !g )
myGraphicsScene->addItem(item);
}
myGraphicsScene->update();
setText(Qobject::tr(“Undo Delete %1“).arg(items.count()));
}
//! [5]
//! [6]
void RemoveShapeCommand::redo()
{
foreach (QGraphicsItem *item items) {
QGraphicsItemGroup *g = dynamic_cast(item->parentItem());
if ( !g )
myGraphicsScene->removeItem(item);
}
setText(Qobject::tr(“Redo Delete %1“).arg(items.count()));
}
//! [6]
//! [7]
AddShapeCommand::AddShapeCommand(QGraphicsItem *item
QGraphicsScene *scene QUndoCommand *parent)
: QUndoCommand(parent)
{
static int itemCount = 0;
myGraphicsScene = scene;
myDiagramItem = item;
initialPosition = item->pos();
++itemCount;
}
//! [7]
AddShapeCommand::~AddShapeCommand()
{
if (!myDiagramItem->scene())
delete myDiagramItem;
}
//! [8]
void AddShapeCommand::undo()
{
myGraphicsScene->removeItem(myDiagramItem);
myGraphicsScene->update();
setText(Qobject::tr(“Undo Add %1“)
.arg(createCommandString(myDiagramItem initialPosition)));
}
//! [8]
//! [9]
void AddSha
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
....... 242 2017-01-28 23:05 qdraw-master\.gitignore
....... 813 2017-01-28 23:05 qdraw-master\app\app.pro
....... 1427 2017-01-28 23:05 qdraw-master\app\app.qrc
....... 10349 2017-01-28 23:05 qdraw-master\app\commands.cpp
....... 3645 2017-01-28 23:05 qdraw-master\app\commands.h
....... 17161 2017-01-28 23:05 qdraw-master\app\customproperty.cpp
....... 3143 2017-01-28 23:05 qdraw-master\app\customproperty.h
....... 50 2017-01-28 23:05 qdraw-master\app\document.cpp
....... 108 2017-01-28 23:05 qdraw-master\app\document.h
....... 41867 2017-01-28 23:05 qdraw-master\app\drawobj.cpp
....... 12333 2017-01-28 23:05 qdraw-master\app\drawobj.h
....... 11388 2017-01-28 23:05 qdraw-master\app\drawscene.cpp
....... 2313 2017-01-28 23:05 qdraw-master\app\drawscene.h
....... 16877 2017-01-28 23:05 qdraw-master\app\drawtool.cpp
....... 2995 2017-01-28 23:05 qdraw-master\app\drawtool.h
....... 9292 2017-01-28 23:05 qdraw-master\app\drawview.cpp
....... 1338 2017-01-28 23:05 qdraw-master\app\drawview.h
....... 2951 2017-01-28 23:05 qdraw-master\app\icons\align_all.png
....... 1009 2017-01-28 23:05 qdraw-master\app\icons\align_bottom.png
....... 1229 2017-01-28 23:05 qdraw-master\app\icons\align_hcenter.png
....... 2256 2017-01-28 23:05 qdraw-master\app\icons\align_height.png
....... 1505 2017-01-28 23:05 qdraw-master\app\icons\align_height.svg
....... 355 2017-01-28 23:05 qdraw-master\app\icons\align_horzeven.png
....... 1192 2017-01-28 23:05 qdraw-master\app\icons\align_left.png
....... 1141 2017-01-28 23:05 qdraw-master\app\icons\align_right.png
....... 1199 2017-01-28 23:05 qdraw-master\app\icons\align_top.png
....... 1223 2017-01-28 23:05 qdraw-master\app\icons\align_vcenter.png
....... 344 2017-01-28 23:05 qdraw-master\app\icons\align_verteven.png
....... 2001 2017-01-28 23:05 qdraw-master\app\icons\align_width.png
....... 1777 2017-01-28 23:05 qdraw-master\app\icons\align_width.svg
............此处省略325个文件信息
相关资源
- 酒店管理系统基于Qt Creator5)
- vtk QT做的三维地质可视化系统2of2
- Qt局域网聊天软件
- Qt Creator opengl实现四元数鼠标控制轨迹
- QT局域网聊天系统(基于QT5.修改过)
- qt-电子点菜系统
- C 餐厅叫号系统(QT平)
- QT 实现文件下载
- qt图像处理
- QT,JPEG解码源代码(已完成)
- Qt 播放音频文件
- Qt 读取16进制的data文件
- MQTT+串口(usart)透传
- 易语言QQTEA算法源码
- VC工程转Qt工程文件的工具
- MQTT推送Demo
- 基于Linux、QT的视频监控系统的设计与
- Qt 百度地图 定位
- QT酷炫界面开发指南《QmlBook》
- Ubuntu下操作Excel,qt代码
- Qt图片浏览器 --基于Qt的Graphics View f
- qtnribbon2破解
- Qt软件开发 完整项目代码
- MQTT_3.1protocol_Specific中文版
- 在QT中使用RTP进行视频的采集和传输
- Mini6410 Qt4和Qtopia编程开发指南
- Qt实现Code39条形码
- qt_ffmpeg_mp4_export_and_import.zip
- QT5.5入门与项目实战
- Huffman Compress 霍夫曼编码 压缩 解压缩
评论
共有 条评论