重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

CTK框架——CTKWidgets快速入门

CTK框架——CTK Widgets快速入门

一、CTK Widgets模块简介

1、CTK Widgets模块简介

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/ImageGallery

成都创新互联专业为企业提供塔什库尔干塔吉克网站建设、塔什库尔干塔吉克做网站、塔什库尔干塔吉克网站设计、塔什库尔干塔吉克网站制作等企业网站建设、网页设计与制作、塔什库尔干塔吉克企业网站模板建站服务,十余年塔什库尔干塔吉克做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

2、CTK Widgets构成

CTK Widgets模块主要包含4部分:
CTK框架——CTK Widgets快速入门
A、DICOM Widgets:用于支持医学数字影像通信(DICOM)领域的应用
CTK框架——CTK Widgets快速入门
B、Visualization VTK Widgets:支持VTK的组件
CTK框架——CTK Widgets快速入门
C、Widgets:通用的功能组件
CTK框架——CTK Widgets快速入门
CTK框架——CTK Widgets快速入门
CTK框架——CTK Widgets快速入门
CTK框架——CTK Widgets快速入门
CTK框架——CTK Widgets快速入门
D、XNAT Widgets:支持XNAT的组件
目前只包含一个类ctkXnatLoginDialog。
XNAT是华盛顿大学神经信息学研究小组开发的开源成像信息平台,最初在华盛顿大学的巴克纳实验室开发,目前由哈佛大学开发。

二、CTK Widgets快速入门

1、导入CTK Widgets模块

CTKWidgets模块使用与其它第三方库一样。
创建一个QtGUI应用并在工程文件中加入CTKWidgets模块。

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

2、使用CTK Widgets模块中的组件

#ifndef WIDGET_H
#define WIDGET_H

#include 
#include 

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

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 

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Widget w;
    w.show();

    return a.exec();
}

3、CTK Widgets应用编译结果

CTK框架——CTK Widgets快速入门

4、CTK Widgets学习示例

CTK Widgets测试代码位于CTK/Libs/Widgets/Testing/Cpp中,可以作为学习示例。


网站标题:CTK框架——CTKWidgets快速入门
地址分享:http://cqcxhl.com/article/iheipg.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP