Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. ‘vtkEventQtSlotConnect’ does not name a type
Qt 6.12 LTS is out! See what's new in the release blog

‘vtkEventQtSlotConnect’ does not name a type

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 932 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lyccyl1
    wrote on last edited by
    #1

    I am building a project with cmake .
    The project is to read DICOM by vtk.
    I meet a error: ‘vtkEventQtSlotConnect’ does not name a type.
    Here is my code ```
    //ReadDICOM.cpp
    #include "ReadDICOMQt.h"
    #include "ui_ReadDICOMQt.h"
    #include <QFileDialog>

    ReadDICOMQt::ReadDICOMQt(QWidget *parent) : QMainWindow(parent), ui(new Ui::ReadDICOMQt) {
    ui->setupUi(this);
    reader = vtkSmartPointer<vtkDICOMImageReader>::New();
    viewer = vtkSmartPointer<vtkImageViewer>::New();

    m_Connections = vtkEventQtSlotConnect::New();
    m_Connections->Connect(m_QVTKWidget->GetRenderWindow()->GetInteractor(),
                 vtkCommand::MouseMoveEvent,
                 this,
                 SLOT(updateCoords(vtkObject*)));
    

    //vtkNew<vtkGenericOpenGLRenderWindow> renderWindow;
    //vtkNew<vtkRenderer> renderer;
    //vtkNew<vtkImageSlice> imageSlice;
    //vtkNew<vtkImageResliceMapper> mapper;
    //vtkNew<vtkInteractorStyleImage> interactorStyle;
    }

    ReadDICOMQt::~ReadDICOMQt() {
    delete ui;
    }

    void ReadDICOMQt::openDICOMFile() {
    QString fileNameDICOM = QFileDialog::getOpenFileName(this, tr("Select DICOM File"), QDir::currentPath());
    drawDICOMImage(fileNameDICOM.toUtf8().constData());
    }
    void ReadDICOMQt::updateCoords(int obj){
    // 获取交互器
    vtkRenderWindowInteractor
    iren = vtkRenderWindowInteractor::SafeDownCast(obj);

    // 获取鼠标的当前位置
    int event_pos[2];
    iren->GetEventPosition(event_pos);
    
    QString str;
    str.sprintf("x=%d : y=%d", event_pos[0], event_pos[1]);
    m_StatusBar->showMessage(str);
    

    }
    void ReadDICOMQt::drawDICOMImage(std::string fileDICOM) {
    // 获取DICOM图像的文件夹
    reader->SetFileName(fileDICOM.c_str());
    reader->Update();
    // 将输入与viewer结合起来
    viewer->SetInputConnection(reader->GetOutputPort());
    // 将widght 链接到viewer
    ui->qvtkWidget->SetRenderWindow(viewer->GetRenderWindow());
    //向viewer添加interactor
    viewer->SetupInteractor(ui->qvtkWidget->GetInteractor());
    // init
    viewer->Render();

    // 更新GUI label
    ui->labelFileName->setText(QString::fromStdString(fileDICOM));

    }

    void ReadDICOMQt::on_buttonOpenFile_clicked() {
    openDICOMFile();
    }
    //ReadDICOM.h
    #ifndef READDICOMQT_H
    #define READDICOMQT_H

    #include <QMainWindow>
    #include <vtkSmartPointer.h>
    #include <vtkDICOMImageReader.h>
    #include <vtkImageViewer.h>

    namespace Ui {
    class ReadDICOMQt;
    }

    class ReadDICOMQt : public QMainWindow {
    Q_OBJECT

    public:
    explicit ReadDICOMQt(QWidget *parent = 0);
    ~ReadDICOMQt();

    private slots:
    void openDICOMFile();
    void drawDICOMImage(std::string fileDICOM);
    void on_buttonOpenFile_clicked();
    void updateCoords(vtkObject* obj);

    private:
    Ui::ReadDICOMQt ui;
    vtkSmartPointer<vtkDICOMImageReader> reader;
    vtkSmartPointer<vtkImageViewer> viewer;
    vtkEventQtSlotConnect
    m_Connections;
    };
    #endif // READDICOMQT_H

    The error occurred  when I make the makefile
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You are missing the include that defines that class. See its documentation.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      L 2 Replies Last reply
      1
      • SGaistS SGaist

        Hi and welcome to devnet,

        You are missing the include that defines that class. See its documentation.

        L Offline
        L Offline
        lyccyl1
        wrote on last edited by
        #3

        @SGaist said in ‘vtkEventQtSlotConnect’ does not name a type:

        Hi and welcome to devnet

        sorry. Is it means that though I uses CMAKE I should define that class?

        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi and welcome to devnet,

          You are missing the include that defines that class. See its documentation.

          L Offline
          L Offline
          lyccyl1
          wrote on last edited by
          #4

          @SGaist thanks a lot . You are so nice man.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            No, it's unrelated to cmake. You need to include the header in the file where you use an instance of the class.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt
            • Unsolved