现在才看到HelloWorld
文章目录
1 官方示例展示
2 代码搬运
2.1helloworld.h
2.2helloworld.cpp
3 运行效果
★ 源码 ★
1 官方示例展示
这HelloWorld跑这里来了。这个应该是第一个出现的,跑这里就跑这里来吧。
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; }