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

目录
相关文章
|
编译器 C++ Windows
Qt&Vtk-001-编译
本文主要记录了博主在尝试编译VTK源码中遇到的问题,同时也感谢前辈的无私分享,使我们可以跟着前辈的步伐学习进步。
122 0
Qt&Vtk-001-编译
Qt&Vtk-023-MultiView
Qt&Vtk-023-MultiView
126 0
Qt&Vtk-023-MultiView
Qt&Vtk-015-Cylinder
Qt&Vtk-015-Cylinder
118 0
Qt&Vtk-015-Cylinder
Qt&Vtk-012-CreateTree
Qt&Vtk-012-CreateTree
126 0
Qt&Vtk-012-CreateTree
Qt&Vtk-027-RGrid
Qt&Vtk-027-RGrid
117 0
Qt&Vtk-027-RGrid
Qt&Vtk-016-DiffuseSpheres
Qt&Vtk-016-DiffuseSpheres
107 0
Qt&Vtk-016-DiffuseSpheres
Qt&Vtk-022-LabeledMesh
Qt&Vtk-022-LabeledMesh
139 0
Qt&Vtk-022-LabeledMesh
Qt&Vtk-020-GraphItem
Qt&Vtk-020-GraphItem
145 0
Qt&Vtk-020-GraphItem
Qt&Vtk-009-Cone4
Qt&Vtk-009-Cone4
99 0
Qt&Vtk-009-Cone4
Qt&Vtk-017-EasyView
Qt&Vtk-017-EasyView
176 0
Qt&Vtk-017-EasyView