本文将主要介绍医学四视图的基本布局。包括轴、矢、冠和3D显示窗口以及一个窗宽窗位调节窗口。
电梯
1 布局
2 代码
2.1 imagemanage.h
2.2 imagemanage.cpp
☞ 源码
1 布局
本模块是还是在ThirdVtk基础上添加一个模块,下图所示:
#ifndef IMAGEMANAGE_H #define IMAGEMANAGE_H #include <QWidget> #include <QSplitter> #include <QHBoxLayout> #include <QVBoxLayout> #include <QGridLayout> #include <QTextEdit> #include <QResizeEvent> #include "QVTKOpenGLWidget.h" //新版本,旧版QVTKWidget #include "vtkAutoInit.h" namespace Ui { class ImageManage; } class ImageManage : public QWidget { Q_OBJECT public: explicit ImageManage(QWidget *parent = nullptr); ~ImageManage(); void setCurrentTab(int temp =0); protected: void resizeEvent(QResizeEvent *event) override; private: Ui::ImageManage *ui; QSplitter *mSplitterMain = nullptr; QSplitter *mSplitterVertical = nullptr; QSplitter *mSplitterUp = nullptr; QSplitter *mSplitterDown = nullptr; }; #endif // IMAGEMANAGE_H
2.2 imagemanage.cpp
#include "imagemanage.h" #include "ui_imagemanage.h" #include <QtDebug> ImageManage::ImageManage(QWidget *parent) : QWidget(parent), ui(new Ui::ImageManage) { ui->setupUi(this); mSplitterMain = new QSplitter(Qt::Horizontal,this); mSplitterVertical = new QSplitter(Qt::Vertical,mSplitterMain); mSplitterUp = new QSplitter(Qt::Horizontal,mSplitterVertical); mSplitterUp->addWidget(ui->widget_1); mSplitterUp->addWidget(ui->widget_2); mSplitterUp->setStretchFactor(0,1); mSplitterUp->setStretchFactor(1,1); mSplitterDown = new QSplitter(Qt::Horizontal,mSplitterVertical); mSplitterDown->addWidget(ui->widget_3); mSplitterDown->addWidget(ui->widget_4); mSplitterDown->setStretchFactor(0,1); mSplitterDown->setStretchFactor(1,1); mSplitterMain->insertWidget(0,mSplitterVertical); mSplitterMain->insertWidget(1,ui->widget_5); mSplitterMain->setStretchFactor(0,1); //很魔性啊 } ImageManage::~ImageManage() { delete ui; } void ImageManage::setCurrentTab(int temp) { } void ImageManage::resizeEvent(QResizeEvent *event) { Q_UNUSED(event); mSplitterMain->resize(this->size()); }