效果預覽
工程目錄樹如下
.
||---headers
| |---mainwindow.h
| |---panel.h
| |---plot.h
| |---settings.h
||---sources
| |---main.cpp
| |---mainwindow.cpp
| |---panel.cpp
| |---plot.cpp
這裡一共有4個.**件,4個.c檔案,涉及到4個主要類:mainwindow、panel、plot、settings。下面逐個瀏覽這些類
mainwindow類
class
mainwindow
:public qmainwindow
;
mainwindow繼承自qmainwindow,兩個槽函式,兩個私有屬性。
建構函式mainwindow實現
mainwindow::
mainwindow
( qwidget *parent )
:qmainwindow
( parent )
下面是兩個槽函式
void mainwindow::
updateplot()
//乙個槽函式,當面板上的資訊發生改變時,面板物件會發出乙個edited訊號,mainwindow會接收到
void mainwindow::
exportplot()
//乙個槽函式,繫結在乙個按鈕上,用來將影象匯出
panel類
#include
"settings.h"
#include
class
qcheckbox
;class
qcombobox
;class
qspinbox
;class
qlineedit
;class
panel
:public qwidget
d_legend;
struct
d_legenditem;
struct
d_curve;
};
建構函式panel實現
panel::
panel
( qwidget *parent )
:qwidget
( parent )
重點理解qt中的訊號到訊號的連線,進一步熟悉qt中布局類的使用
setsettings實現,用於設定控制面板
void panel::
setsettings
(const settings &settings)
settings實現,用於獲取當前控制面板的設定資訊
settings panel::
settings()
const
plot類,繼承自qwtplot,乙個畫板類
#include
class
settings
;class
legenditem
;class
qwtlegend
;class
plot
:public qwtplot
;
建構函式plot
plot::
plot
( qwidget *parent )
:qwtplot
( parent )
,d_externallegend
(null),
d_legenditem
(null),
d_isdirty
(false
)
void plot::
(const settings &settings )
if( d_externallegend ==
null)}
else}}
else
if( settings.legenditem.isenabled )
d_legenditem-
>
setmaxcolumns
( settings.legenditem.numcolumns )
; d_legenditem-
>
setalignment
( qt::
alignment
( settings.legenditem.alignment ));
d_legenditem-
>
setbackgroundmode
( qwtplotlegenditem::
backgroundmode
( settings.legenditem.backgroundmode ));
if( settings.legenditem.backgroundmode ==
qwtplotlegenditem::itembackground )
else
qfont font = d_legenditem-
>
font()
; font.
setpointsize
( settings.legenditem.size )
; d_legenditem-
>
setfont
( font );}
else
qwtplotitemlist curvelist =
itemlist
( qwtplotitem::rtti_plotcurve );if
( curvelist.
size()
!= settings.curve.numcurves )
for(
int i = curvelist.
size()
; i < settings.curve.numcurves; i++
)insertcurve()
;}curvelist =
itemlist
( qwtplotitem::rtti_plotcurve )
;for
(int i =
0; i < curvelist.
count()
; i++
)setautoreplot
(false);
if( d_isdirty )
}
要點總結: C 基礎教程之引用
c 引用 引用變數是乙個別名,也就是說,它是某個已存在變數的另乙個名字。一旦把引用初始化為某個變數,就可以使用該引用名稱或變數名稱來指向變數。c 引用 vs 指標 引用很容易與指標混淆,它們之間有三個主要的不同 不存在空引用。引用必須連線到一塊合法的記憶體。一旦引用被初始化為乙個物件,就不能被指向到...
C 基礎教程之指標
學習 c 的指標既簡單又有趣。通過指標,可以簡化一些 c 程式設計任務的執行,還有一些任務,如動態記憶體分配,沒有指標是無法執行的。所以,想要成為一名優秀的 c 程式設計師,學習指標是很有必要的。例項 include using namespace std int main 當上面的 被編譯和執行時...
python基礎教程之Hello World
python命令列 假設你已經安裝好了python,那麼在linux命令列輸入程式設計客棧 複製 如下 python 將直接進入python。後面輸入 複製 如下 print hello world 可以看到,隨後在螢幕上輸出 複製 如下 hello world print是乙個常用函式,其功能就是...