A simple Qt example

Here we describe the complete example available in the Example directory.

The example uses a gui generated with Qt Designer.

We define a class called Dicom (why not ?) that will embed QtDcm widgets.

class Dicom : public QMainWindow
{
Q_OBJECT
private:
public:
Ui::Dicom ui;
Dicom( QWidget *parent = 0 );
void
initConnections();
public slots:
void
void
void
};

Let's take a look at the constructor:

Dicom::Dicom ( QWidget *parent ) : QMainWindow ( parent )
{
ui.setupUi ( this );
QtDcmManager::instance()->setSerieInfoWidget ( ui.serieInfoWidget );
QtDcmManager::instance()->setPreviewWidget ( ui.previewWidget );
QtDcmManager::instance()->setImportWidget ( ui.importWidget );
initConnections();
}

Now let's detail the constructor:

First we instanciate the gui objects.

ui.setupUi(this);

Then we set the settings file of qtdcm that will be used to initialize the QtDcmPreferences object.

Then we give QtDcmManager the pointers to the specific widgets: QtDcm, QtDcmSerieInfoWidget, QtDcmPreviewWidget and QtDcmImportWidget.

Finally, we configure the manager to set the output directory (for conversion to nifti) using a QFileDialog box. The other mode available is QtDcmManager::CUSTOM

Now let's detail the class slots. I think we are ok with the initConnection() method.

The Dicom::openDicomdir() slot is very simple because we directly call the method QtDcm::openDicomdir(). The dicomdir path can be set manually using QtDcmManager::setDicomdir() and the dicomdir can be loaded using QtDcm::loadPatientsFromDicomdir()

void
{
ui.qtdcm->openDicomdir();
}

The Dicom::exportSerie() slot is also very simple. We directly use the QtDcmManager::importSelectedSeries()

Finally the Dicom::preferences() slot displays a QDialog for setting the application preferences. The called method is QtDcm::editPreferences(). It is also possible to set the preferences from an embedded widget, see QtDcmPreferencesWidget, QtDcmLocalDicomSettingsWidget and QtDcmServersDicomSettingsWidget classes.

void
{
ui.qtdcm->editPreferences();
}

To watch the full code, see dicom.h, dicom.cpp and main.cpp