DCMTK and QT problems

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Polielia
Posts: 3
Joined: Thu, 2017-02-23, 15:23

DCMTK and QT problems

#1 Post by Polielia »

Hi, i'm trying to make a program in Qt that take visualize a image in a QLabel and then I do things with the image.
i have write the code and create the GUI and it works fine for jpeg file. But I have to visualize images from dcm format so now I have to add some code for manage the dcm format.

I have read a lot of guide but I'm not able to use the DCMTK libraries.
I've done:
+download dcmtk-3.6.0;
+download cmake-3.8.0-rc1-win64-x64;
+use cmake and configure the project for visual studio 14;
+In the Qt .pro file i've add the code:

Code: Select all

INCLUDEPATH += C:/Users/.../DCMTK/include

LIBS += -L C:/Users/.../DCMTK/lib \
-ladvapi32 \
-ldcmdata \
-loflog \
-lofstd \
-lws2_32 \
-lnetapi32 \
-lwsock32

I found on web this, is right ?

when i go to my mainwindows i can add the libraries and if I write some code it is recognize from the editor (the color of the words change) but when i try to run I have these errors:

Code: Select all

C:\Users\...\DCMTK\include\dcmtk\ofstd\offile.h:200: error: cannot convert 'bool' to 'FILE* {aka _iobuf*}' in assignment
     file_ = _popen(command, modes);

C:\Users\...\DCMTK\include\dcmtk\ofstd\offile.h:262: error: no matching function for call to 'OFFile::_pclose(FILE*&)'
         result = _pclose(file_);
and I can't make any kind of test because every code I write give the same errors.
I use:
- windows 10
- Qt 5.1.1 MinGW 32bit

what I'm doing wrog? :roll: :roll:

Jan Schlamelcher
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 318
Joined: Mon, 2014-03-03, 09:51
Location: Oldenburg, Germany

Re: DCMTK and QT problems

#2 Post by Jan Schlamelcher »

Perhaps try a more recent snapshot, I can somewhat remember that there was a problem with _popen etc. being a #define in MinGW, that I fixed by adding brakets to prevent macro expansion. Also, why do you use MinGW but setup the project for Visual Studio?

Polielia
Posts: 3
Joined: Thu, 2017-02-23, 15:23

Re: DCMTK and QT problems

#3 Post by Polielia »

Jan Schlamelcher wrote: Also, why do you use MinGW but setup the project for Visual Studio?
I have setup the project for visual studio because with MinGW i had some errors, do you think that if I use the VS compiler in Qt should be better?
being a #define in MinGW, that I fixed by adding brakets to prevent macro expansion
Can you explain me better this? because the line error are:
Line 200 in offile.h:

Code: Select all

196  OFBool popen(const char *command, const char *modes)
197  {
198    if (file_) fclose();
199  #ifdef _WIN32
200    file_ = _popen(command, modes);
201 #else
202    file_ = :: popen(command, modes);
203 #endif
204    if (file_) popened_ = OFTrue; else storeLastError();
205    return (file_ != NULL);
  }


Line 262 in offile.h

Code: Select all

254  int fclose()
255  {
256    int result = 0;
257    if (file_)
258    {
259      if (popened_)
260      {
261#ifdef _WIN32
262        result = _pclose(file_);
263#else
264        result = :: pclose(file_);

Jan Schlamelcher
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 318
Joined: Mon, 2014-03-03, 09:51
Location: Oldenburg, Germany

Re: DCMTK and QT problems

#4 Post by Jan Schlamelcher »

It seems my memory was wrong, however, this should be the fix for your problem.

Polielia
Posts: 3
Joined: Thu, 2017-02-23, 15:23

Re: DCMTK and QT problems

#5 Post by Polielia »

Thanks, now i'm able to use the library.
Now I want to visualize a DICOM image into a QLabel.
I have already write the code for a jpg image using QPixmap and visualize it using SetPixmap for the Label. so how can I do this with the DICOM image?

Code: Select all

QString Imagename = QFileDialog::getOpenFileName(this,tr("Open Image ), "", DICOM(*.dcm)"));  //get the image to open

DicomImage *Dimage = new DicomImage (Imagename); // Imagename is a QString, how can combine it with this function that need a char? also if i write a normal name like ("test.dcm") i got an error                                            undefined reference to `DicomImage::DicomImage(char const*, unsigned long, unsigned long, unsigned long)'
Uint8 *pixeldata = (Uint8*) (Dimage->getOutputData(8)); // can I use this data for visualize the image in the QLabel?



Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest