Integrating QtDcm in a Qt application

The integration of QtDcm in a Qt application is very easy but you have to know how to configure it via QtDcmManager which is in charge of the connections between the different widgets, dicom communications, dicom images downloads and image conversions (or command line tools).

Important note: for the moment, QtDcm can only be integrated in Qt based applications and more precisely QtWidgets based applications.

Instanciating the objects

In your application you have to first instanciate the widgets. Here we only show the case with the main QtDcm and the QtDcmImportWidget, assuming "this" is the parent widget embedding those widgets.

QtDcm * mainWidget = new QtDcm(this);
QtDcmImportWidget * importWidget = new QtDcmImportWidget(this);

Then you have to set the setting file. This file is stored in your personnal directory and if it doesn't exist it's created with default values.

Set the QtDcmManager class the pointers to the main widgets (QtDcm, QtDcmImportWidget for example). All the connexions are perfomed internally by QtDcmManager.

QtDcmManager configuration options

Depending on what you planned to do with this library, it's possible to set behaviour options to QtDcmManger. This behaviour mostly relies on the way dicom data are converted and where they are stored. First there's a mode that you can set if you want to control from the code where the converted data will be stored. See QtDcmManager::outputdirmode enum. If you choose QtDcmManager::DIALOG, the output directory will be set using a QFileDialog. If you choose QtDcmManager::CUSTOM, you will have to set manually the output directory.

...
QtDcmManager::instance()->importSelectedSeries();

The other option is the choice of the provided converter : using a call to dcm2nii binary or using an ITK based conversion class.

QtDcmManager::instance()->setExternalUseConverter(true);
...
or
...
QtDcmManager::instance()->setExternalUseConverter(false);

Playing with the settings widgets

There a lots of way to play with settings. By default, the settings are used to configure dicom related stuff, like local dicom settings (AETitle, port, IP) or available dicom servers. There are also settings for the Dcm2nii conversion tool (if you want to use it).

The easiest way: calling the QtDcmPreferencesDialog class

You just need to call the slot QtDcm::editPreferences()

QtDcm * main = new QtDcm(this);

Used the specific settings widgets

These widgets are designed to be integrated in other applications/widgets, in fact you can just use them where you want, assuming the parent class is QWidget based. You just need to instanciate them and they will internally update the QtDcmPreferences instance but the changes won't be written to the settings file.

p_servers = new QtDcmServersDicomSettingsWidget(this); // assuming p_servers is a member of the parent widget

In this way it's necessary to add somewhere in your application a way to store the settings, e.g a "Save" button connected to an onSaveClicked() slot. Here is the instanciation of the button and the signal/slot connection.

//instanciate a QPushButton
QPushButton * save = new QPushButton(this);
connect(save, &QPushButton::clicked,
this, &MyParentWidget::onSaveClicked);

Here is the slot implementation:

void MyClass::onSaveClicked()
{
m_servers->updatePreferences(); // Updates preferences in memory
QtDcmPreferences::instance()->writeSettings(); // Effectively writes them to the settings file
}