Qt&Vtk-021-HelloWorld

简介: Qt&Vtk-021-HelloWorld

image.png现在才看到HelloWorld


文章目录


1 官方示例展示

2 代码搬运

2.1helloworld.h

2.2helloworld.cpp

3 运行效果

★ 源码 ★

1 官方示例展示

这HelloWorld跑这里来了。这个应该是第一个出现的,跑这里就跑这里来吧。

image.png

2 代码搬运


2.1helloworld.h


#ifndef HELLOWORLD_H
#define HELLOWORLD_H
#include <QWidget>
#include "vtkGraphLayoutView.h"
#include "vtkRandomGraphSource.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
namespace Ui {
class HelloWorld;
}
class HelloWorld : public QWidget
{
    Q_OBJECT
public:
    explicit HelloWorld(QWidget *parent = 0);
    ~HelloWorld();
private:
    Ui::HelloWorld *ui;
};
#endif // HELLOWORLD_H

2.2helloworld.cpp


#include "helloworld.h"
#include "ui_helloworld.h"
HelloWorld::HelloWorld(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::HelloWorld)
{
    ui->setupUi(this);
    vtkRandomGraphSource *source = vtkRandomGraphSource::New();
    vtkGraphLayoutView *view = vtkGraphLayoutView::New();
    view->SetRepresentationFromInputConnection(source->GetOutputPort());
    view->SetRenderWindow(ui->widget->GetRenderWindow());
    view->ResetCamera();
    view->Render();
}
HelloWorld::~HelloWorld()
{
    delete ui;
}

image.pngimage.png

目录
相关文章
Qt&Vtk-023-MultiView
Qt&Vtk-023-MultiView
161 0
Qt&Vtk-023-MultiView
Qt&Vtk-006-one
Qt&Vtk-006-one
135 0
Qt&Vtk-006-one
Qt&Vtk-027-RGrid
Qt&Vtk-027-RGrid
168 0
Qt&Vtk-027-RGrid
Qt&Vtk-015-Cylinder
Qt&Vtk-015-Cylinder
152 0
Qt&Vtk-015-Cylinder
Qt&Vtk-022-LabeledMesh
Qt&Vtk-022-LabeledMesh
177 0
Qt&Vtk-022-LabeledMesh
Qt&Vtk-008-Cone3
Qt&Vtk-008-Cone3
146 0
Qt&Vtk-008-Cone3
Qt&Vtk-017-EasyView
Qt&Vtk-017-EasyView
209 0
Qt&Vtk-017-EasyView
Qt&Vtk-028-SGrid
Qt&Vtk-028-SGrid
172 0
Qt&Vtk-028-SGrid
Qt&Vtk-012-CreateTree
Qt&Vtk-012-CreateTree
167 0
Qt&Vtk-012-CreateTree
Qt&Vtk-011-Cone6
Qt&Vtk-011-Cone6
173 0
Qt&Vtk-011-Cone6