资源简介
Qt做的画图程序的源代码,已在Qt4上通过运行
代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include “CentralWidget.h“
#include “MainWindowframework.h“
#include “GraphLine.h“
#include “GraphRect.h“
#include “Graphics.h“
using namespace KING;
using namespace std;
QCentralWidget::QCentralWidget(QWidget* parent Qt::WindowFlags f)
: QWidget(parent f)
m_eGraphicsType(NONE)
m_pSelectedGraph(NULL)
{
QMainWindowframework* pframe = (QMainWindowframework*)parentWidget();
pframe->actionLine->setChecked(m_eGraphicsType == LINE);
pframe->actionLine->setChecked(m_eGraphicsType == RECT);
}
void QCentralWidget::onGraphicsLine(bool bChecked)
{
m_eGraphicsType = bChecked ? LINE : NONE;
QMainWindowframework* pframe = (QMainWindowframework*)parentWidget();
pframe->actionLine->setChecked(m_eGraphicsType == LINE);
pframe->actionRect->setChecked(m_eGraphicsType == RECT);
}
void QCentralWidget::onGraphicsRect(bool bChecked)
{
m_eGraphicsType = bChecked ? RECT : NONE;
QMainWindowframework* pframe = (QMainWindowframework*)parentWidget();
pframe->actionLine->setChecked(m_eGraphicsType == LINE);
pframe->actionRect->setChecked(m_eGraphicsType == RECT);
}
void QCentralWidget::onRemove()
{
if(m_eGraphicsType == NONE && m_pSelectedGraph != NULL)
{
/**
for(list::iterator itGraph = m_lstGraph.begin();
itGraph != m_lstGraph.end(); itGraph++)
{
if(*itGraph == m_pSelectedGraph)
{
m_lstGraph.erase(itGraph);
delete(m_pSelectedGraph);
m_pSelectedGraph = NULL;
repaint(0 0 1000 1000);
return;
}
}
*/
QRect rect(m_pSelectedGraph->GetTopLeft().GetX() m_pSelectedGraph->GetTopLeft().GetY()
m_pSelectedGraph->GetWidth() m_pSelectedGraph->GetHeight());
QRect rectNormal(rect.normalized());
rectNormal.adjust(-5 -5 5 5);
m_lstGraph.remove(m_pSelectedGraph);
delete m_pSelectedGraph;
m_pSelectedGraph = NULL;
repaint(rectNormal);
}
}
void QCentralWidget::onUp()
{
}
void QCentralWidget::onDown()
{
}
void QCentralWidget::onUpTop()
{
}
void QCentralWidget::onDownButton()
{
}
void QCentralWidget::mousePressEvent(QMouseEvent * event)
{
m_pSelectedGraph = NULL;//清空指针
if(m_eGraphicsType == NONE)//移动图形
{
for(list::reverse_iterator ritGraph = m_lstGraph.rbegin();
ritGraph != m_lstGraph.rend(); ritGraph++)
{
CGraphics* pGraph = *ritGraph;
QRect rRect(pGraph->GetTopLeft().GetX() pGraph->GetTopLeft().GetY() pGraph->GetWidth() pGraph->GetHeight());
if(rRect.contains(event->pos()))//选中图形
{
m_pSelectedGraph = pGraph;
m_posPoint = event->pos();
//选中加框
//.....
/*QString strMsg(tr(“选中图形!“));
QMainWindowframework* pframe = (QMainWindowframework*)parentWidget();
pframe->statusBar()->showMessage(strMsg);
return;*/
}
}
}
else//添加图形
{
if (Qt::LeftButton == event->button())
相关资源
- 酒店管理系统基于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——十分好用的画图工具
评论
共有 条评论