CTK Widgets模塊是CTK封裝的用於通用功能以及生物醫學成像專用領域的Qt組件庫。
CTK中全部部分都有大量的測試相關代碼,在源碼目錄下Libs/xxx/Testin/Cpp目錄中。
CTK官方文檔:
http://www.commontk.org/docs/html/modules.html
ImageGallery演示了CTK Widgets模塊大部分組件的效果:
http://www.commontk.org/index.php/Documentation/ImageGalleryphp
CTK Widgets模塊主要包含4部分:
A、DICOM Widgets:用於支持醫學數字影像通訊(DICOM)領域的應用
B、Visualization VTK Widgets:支持VTK的組件
C、Widgets:通用的功能組件
D、XNAT Widgets:支持XNAT的組件
目前只包含一個類ctkXnatLoginDialog。
XNAT是華盛頓大學神經信息學研究小組開發的開源成像信息平臺,最初在華盛頓大學的巴克納實驗室開發,目前由哈佛大學開發。html
CTKWidgets模塊使用與其它第三方庫同樣。
建立一個QtGUI應用並在工程文件中加入CTKWidgets模塊。app
QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = HelloCTKWidget TEMPLATE = app #CTK安裝路徑 CTK_INSTALL_PATH = /usr/local/CTK #CTK插件相關庫所在路徑 CTK_LIB_PATH = $$CTK_INSTALL_PATH/lib/ctk-0.1 #CTK插件相關頭文件所在路徑 CTK_INCLUDE_PATH = $$CTK_INSTALL_PATH/include/ctk-0.1 LIBS += -L$$CTK_LIB_PATH -lCTKCore -lCTKWidgets INCLUDEPATH += $$CTK_INCLUDE_PATH SOURCES += main.cpp\ Widget.cpp HEADERS += Widget.h
#ifndef WIDGET_H #define WIDGET_H #include <QWidget> #include <QGridLayout> #include <ctkCheckablePushButton.h> #include <ctkCollapsibleButton.h> #include <ctkColorPickerButton.h> #include <ctkRangeWidget.h> #include <ctkCollapsibleGroupBox.h> #include <ctkCoordinatesWidget.h> #include <ctkTreeComboBox.h> #include <ctkSearchBox.h> #include <ctkDirectoryButton.h> #include <ctkCheckableComboBox.h> #include <ctkMaterialPropertyWidget.h> #include <ctkMatrixWidget.h> #include <ctkPathLineEdit.h> class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = 0) { m_layout = new QGridLayout(this); //複選按鈕 m_ctkCheckableButton = new ctkCheckablePushButton(this); m_ctkCheckableButton->setText("ctkCheckablePushButton"); //可摺疊按鈕 m_ctkCollapsibleButton = new ctkCollapsibleButton(this); m_ctkCollapsibleButton->setText("ctkCollapsibleButton"); m_layout->addWidget(m_ctkCheckableButton, 0, 0, 1, 2); m_layout->addWidget(m_ctkCollapsibleButton, 0, 2, 1, 2); //顏色拾取器 m_ctkColorPickerButton = new ctkColorPickerButton(this); m_ctkColorPickerButton->setText("ctkColorPickerButton"); //滑塊 m_ctkRangeWidget = new ctkRangeWidget(this); m_layout->addWidget(m_ctkColorPickerButton, 1, 0, 1, 2); m_layout->addWidget(m_ctkRangeWidget, 1, 2, 1, 2); //分組框 m_ctkCollapsibleGroupBox = new ctkCollapsibleGroupBox(this); m_ctkCollapsibleGroupBox->setTitle("GroupBox"); m_layout->addWidget(m_ctkCollapsibleGroupBox, 3, 0, 3, 4); //座標組件 m_ctkCoordinatesWidget = new ctkCoordinatesWidget(this); //樹形組合狂 m_ctkTreeComboBox = new ctkTreeComboBox(this); m_ctkTreeComboBox->addItems(QStringList() << "A" << "B"); m_layout->addWidget(m_ctkCoordinatesWidget, 6, 0, 1, 2); m_layout->addWidget(m_ctkTreeComboBox, 6, 2, 1, 2); //搜索框 m_ctkSearchBox = new ctkSearchBox(this); //目錄按鈕 m_ctkDirectoryButton = new ctkDirectoryButton(this); m_layout->addWidget(m_ctkSearchBox, 7, 0, 1, 2); m_layout->addWidget(m_ctkDirectoryButton, 7, 2, 1, 2); //帶複選功能的組合框 m_ctkCheckableComboBox = new ctkCheckableComboBox(this); m_ctkCheckableComboBox->addItems(QStringList() << "A" << "B"); //路徑行編輯框 m_ctkPathLineEdit = new ctkPathLineEdit(this); m_ctkPathLineEdit->addCurrentPathToHistory(); m_layout->addWidget(m_ctkCheckableComboBox, 8, 0, 1, 2); m_layout->addWidget(m_ctkPathLineEdit, 8, 2, 1, 2); //材料屬性組件 m_ctkMaterialPropertyWidget = new ctkMaterialPropertyWidget(this); //矩陣組件 m_ctkMatrixWidget = new ctkMatrixWidget(this); m_layout->addWidget(m_ctkMaterialPropertyWidget, 9, 0, 1, 2); m_layout->addWidget(m_ctkMatrixWidget, 9, 2, 1, 2); setLayout(m_layout); } private: QGridLayout* m_layout; ctkCheckablePushButton* m_ctkCheckableButton; ctkCollapsibleButton* m_ctkCollapsibleButton; ctkColorPickerButton* m_ctkColorPickerButton; ctkRangeWidget* m_ctkRangeWidget; ctkCollapsibleGroupBox* m_ctkCollapsibleGroupBox; ctkCoordinatesWidget* m_ctkCoordinatesWidget; ctkTreeComboBox* m_ctkTreeComboBox; ctkSearchBox* m_ctkSearchBox; ctkDirectoryButton* m_ctkDirectoryButton; ctkCheckableComboBox* m_ctkCheckableComboBox; ctkMaterialPropertyWidget* m_ctkMaterialPropertyWidget; ctkMatrixWidget* m_ctkMatrixWidget; ctkPathLineEdit* m_ctkPathLineEdit; }; #endif // WIDGET_H
#include "Widget.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); Widget w; w.show(); return a.exec(); }
CTK Widgets測試代碼位於CTK/Libs/Widgets/Testing/Cpp中,能夠做爲學習示例。框架