Important: Please read the Qt Code of Conduct -

How to view dicom images using QT and VTK?

  • Hello,

    I have created GUI using QT.
    Now I need to read dicom images using VTK and load it in qt widget. All I am using in Ubuntu system.
    I have installed VTK 8.2 and QT 4.10 successfully.
    I have checked some example to read dicom series from following sites -

    But I am unable to see images in qtwidget.
    There is no errors. That's why I am unable to understand what is the actual issue?

    P.S. I used the same code in windows system and there it is working fine. I can see dicom images in qt widget.

    So, anyone knows, What is the problem and is it due to Ubuntu system or QT?

    If anyone shares useful code to view dicom images using QT and VTK, that will also really helpful.
    Please help me to solve this issue.

    Thanks in advance.

  • Moderators

    @pvirk said in How to view dicom images using QT and VTK?:

    I have installed VTK 8.2 and QT 4.10 successfully.

    unlikely, as Qt 4.10 does not exist. You may have installed QtCreator 4.10 which is an old version, but possible.

    Please identify the Qt version you use for your project.

    P.S. I used the same code in windows system and there it is working fine. I can see dicom images in qt widget.

    I doubt anyone can help you without you actually posting "the code that works on windows but not on Linux"

  • Thanks for reply.

    I have installed the QT version is 5.13.1 both in Ubuntu and QT 5.12.5 for Windows systems.

    First, I used the same code from
    which is working in windows, but not in Ubuntu.

    The some part of my code is -

    void ReadDICOMSeriesQt::openDICOMFolder() {
    QString folderNameDICOM = QFileDialog::getExistingDirectory(this, tr("Open DICOM Folder"), QDir::currentPath(), QFileDialog::ShowDirsOnly | QFileDialog::DontUseNativeDialog);



    void ReadDICOMSeriesQt::drawDICOMSeries(std::string folderDICOM) {

    renderWindowInteractor = ui->widget->GetInteractor();
    // add slice status message and usage hint message to the renderer

    This part of code is used to view dicom series qt widget by opening folder.
    Could you please check it and tell me what is the problem?
    Also could you please share some code for the same?
    Thanks again.

  • Moderators

    @pvirk said in How to view dicom images using QT and VTK?:


    looking through the code provided, seems like reader reader->SetDirectoryName(folderDICOM.c_str()); does not use QFile so the returned path has probably the wrong folder separation on linux & macOS

    It was probably never meant for cross compilation.
    I would suggest contacting the repo owner 🤷‍♂️

  • Sorry but i am unable to understand the problem.
    The reader used in code is vtkDICOMImageReader which has function SetDirectoryName.

    So you are saying, it will be different on linux system to get the directory path?

    I have asked already to the repo owner, they have also told me that for them there was some issue on linux that time. But they don't remember it now.

    Could you please suggest me some other solution?

  • Lifetime Qt Champion


    If it's really a question of separator you can use QDir::toNativeSeparators for the conversion.

  • Hello,
    Could you please tell me how to use it in my example?

  • Lifetime Qt Champion

    Use it on folderDICOM before passing it further.

Log in to reply