资源简介
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如何实现后台运行即最小化到右下角
- Qt QTableWidget 基本功能及排序功能
- qt-everywhere-opensource-src-5.6.0.tar.gz
- QT之打开文件对话框选择文件
- QT是实现图片得拖拉功能
- QTP自动化测试-相关练习操作视频
- linux Qt4 软键盘
- Qt使用FontAwesome的
- 毕业设计——基于QT的GPS车载导航系统
- Qt实现拼图游戏
-
Qt st
yle Sheets Examples - 提供Qt中快速多次发射信号与耗时槽函
- 基于Qt的坦克大战游戏源码
- Qt5.5 代码实现记事本程序 MiniText
- Qt4第三方库qextserialport
- 多界面跳转切换
- Qt VideoCapture图像采集
- Qt Designer汉化包亲测可用内附说明.z
- Qt 自定义导航栏
- qt黑白棋源码简单
- Qt4.8.4和creator和mingw安装配置说明总结
- 在ARM9和ARMLinux下利用QT编写的实时数据
- 华清远见智能家居项目
- QT实现计算器包含科学计算与进制转换
- qt简易黑白棋代码,不带可执行程序,
- QT text预加载方式显示大文件文本.zi
- 基于linux Qt的仿QQ聊天简单对话框
- QthreadPools.rar
- ESP8266和MQTT协议接收平台下发命令版
- QT编写程序,实现一个坐标轴功能
评论
共有 条评论