本系列目錄
Qt (高仿Visio)流程圖組件開發(fā)(一) 效果展示及基本開發(fā)框架構(gòu)思
Qt (高仿Visio)流程圖組件開發(fā)(二) 基本圖元繪制 圖元間連線繪制
Qt (高仿Visio)流程圖組件開發(fā)(三) 圖元基類如何定義,流程圖多種圖元類型實(shí)現(xiàn)
Qt (高仿Visio)流程圖組件開發(fā)(四) 流程圖 圖元對(duì)齊 磁吸線功能
Qt (高仿Visio)流程圖組件開發(fā)(五) 流程圖 雙擊編輯圖元內(nèi)容實(shí)現(xiàn)
Qt (高仿Visio)流程圖組件開發(fā)(六) 流程圖 線圖元 如何繪制曲線 連接線移除視口后無(wú)法顯示
Qt (高仿Visio)流程圖組件開發(fā)(七) 流程圖 簡(jiǎn)單操作界面搭建
Qt (高仿Visio)流程圖組件開發(fā)(八) 流程圖 鼠標(biāo)拖動(dòng)圖元到場(chǎng)景(QGraphicsScene)創(chuàng)建
Qt (高仿Visio)流程圖組件開發(fā)(九) 流程圖 代碼展示
前言
??本文講解如何為流程圖搭建一個(gè)簡(jiǎn)易界面,將不同功能區(qū)分別封裝為不同的類,方便維護(hù)與后期擴(kuò)展。只是經(jīng)驗(yàn)分享,描述內(nèi)容并不絕對(duì),如有誤差歡迎指正。
一、界面實(shí)現(xiàn)。
??整體布局使用QMainWindow窗口,分為工具欄,圖元工具欄,編輯欄,狀態(tài)欄,圖元編輯區(qū)域。目前只實(shí)現(xiàn)部分簡(jiǎn)單功能。實(shí)現(xiàn)效果如下。
??一些全局的功能存放在頂部工具欄,方便取用。圖元類型全部存放在左側(cè)圖元工具欄,后期開發(fā)其他流程圖圖元,或者UML圖、類圖等等都可以添加在此處顯示。圖元編輯區(qū)域就是我們開發(fā)的FlowchartView(視口類)。
??為了方便開發(fā),建議各部分功能區(qū)自定義自己實(shí)現(xiàn),現(xiàn)有實(shí)現(xiàn)如下。
// 流程圖編輯框
class FlowCharToolButtonBar;
class FlowCharToolSideBar;
class FlowCharWidget : public QMainWindow
{
Q_OBJECT
public:
FlowCharWidget(QWidget *parent = Q_NULLPTR);
// 獲取流程圖數(shù)據(jù)
FlowchartInforBases GetFlowCharData();
// 設(shè)置流程圖數(shù)據(jù)
void SetFlowChartData(FlowchartInforBases _datas);
private:
// 初始化窗體
void InitWindow();
void DataTest();
private:
FlowchartScene* scene_; // 流程圖編輯界面
FlowCharToolSideBar* tool_side_bar_; // 左側(cè)形狀菜單
FlowCharToolButtonBar* tool_button_bar_; // 頂層工具欄
};
//*******************************工具欄************************************
class FlowCharToolButtonBar : public QToolBar
{
Q_OBJECT
public:
FlowCharToolButtonBar(QWidget *parent = Q_NULLPTR);
~FlowCharToolButtonBar();
// 傳入場(chǎng)景對(duì)象
void SetFlowchartScene(FlowchartScene* _scene);
// 傳入形狀欄
void SetToolSideBar(FlowCharToolSideBar* _side_bar);
private:
// 初始化界面
void InitWidget();
// 文件保存
void FileSave();
// 文件讀取
void FileRead();
private slots:
// action通用槽函數(shù)
void FlowActionSlot();
private:
// 設(shè)置鼠標(biāo)狀態(tài) 指針工具 連接線
QAction *mouse_status_nomal_, *mouse_status_link_;
// 形狀
QAction *item_type_;
// 保存為文件 讀取文件
QAction* file_save_, * file_read_;
FlowchartScene* scene_;
FlowCharToolSideBar* side_bar_;
// 測(cè)試數(shù)據(jù)
FlowchartInforBases datas;
};
//*******************************左側(cè)工具欄************************************
class FlowCharToolSideBar : public QDockWidget
{
Q_OBJECT
public:
FlowCharToolSideBar(QWidget *parent = Q_NULLPTR);
~FlowCharToolSideBar();
void SetFlowchartScene(FlowchartScene* _scene);
private:
void InitWidget();
void InitData();
private slots:
void FlowButtonSlot();
private:
QStackedWidget* stacked_widget_;
FlowchartScene* scene_;
QMap<std::string, QPushButton*> vec_btn_;
};
總結(jié)
本文主要講解界面如何搭建。
本文只是經(jīng)驗(yàn)分享,描述內(nèi)容并不絕對(duì),如有誤差歡迎指正。文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-424269.html
如果此文幫助到你( ?? ω ?? )?,動(dòng)動(dòng)小手點(diǎn)個(gè)贊可好O(∩_∩)O。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-424269.html
原創(chuàng)文章,轉(zhuǎn)載請(qǐng)標(biāo)明本文出處。到了這里,關(guān)于Qt (高仿Visio)流程圖組件開發(fā)(七) 流程圖 簡(jiǎn)單操作界面搭建的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!