Difference between revisions of "Documentation/4.0/Developers/Tutorials/ModuleWriting"

From Slicer Wiki
Jump to: navigation, search
Line 26: Line 26:
 
= Qt Creator =
 
= Qt Creator =
 
[http://qt.nokia.com/products/developer-tools?currentflipperobject=821c7594d32e33932297b1e065a976b8 Qt Creator] is a cross-platform IDE that fully integrates Qt into the development of applications. Slicer CMake project is supported by Qt Creator, the following describes tips using Qt Creator.  
 
[http://qt.nokia.com/products/developer-tools?currentflipperobject=821c7594d32e33932297b1e065a976b8 Qt Creator] is a cross-platform IDE that fully integrates Qt into the development of applications. Slicer CMake project is supported by Qt Creator, the following describes tips using Qt Creator.  
* launch qtcreator through slicer to setup paths and paths to paths:
+
 
  Slicer4 --launch /your/qtcreator/location
+
* Launch qtcreator through slicer to setup paths and paths to paths (this allows qtcreator to locate our custom designer plugins):
* turn off verbose make using this from Slicer-build:
+
  Slicer4 --launch /path/to/qtcreator
 +
 
 +
* Configure and compile Slicer outside qtcreator first, from command line.
 +
 
 +
* Open /path/to/Slicer-src/CMakeLists.txt in qtcreator, when prompted, choose the build directory where Slicer was configured and compiled in the previous step. (/path/to/Slicer-Superbuild/Slicer-build)
 +
 
 +
* Turn off verbose make using this from Slicer-build:
 
  cmake -D CMAKE_VERBOSE_MAKEFILE:BOOL=OFF .
 
  cmake -D CMAKE_VERBOSE_MAKEFILE:BOOL=OFF .
* comnfigure and compile Slicer outside qtcreator first, from command line
 
* open CMakeLists.txt in qtcreator, when prompted, choose the build directory where Slicer was configured and compiled in the previous step
 

Revision as of 00:31, 28 January 2011

Home < Documentation < 4.0 < Developers < Tutorials < ModuleWriting

QtSlicer/Tutorials

Initialization

  • Create the Module directory
cd Slicer4
python Scripts/ModuleWizard.py MY_MODULE_NAME

Note: on Windows

..\Slicer4-Superbuild\python-build\PCBuild\python.exe Scripts\ModuleWizard.py MY_MODULE_NAME
  • Add the newly created module into Slicer4/QTModules/CMakeLists.txt
  • Compile
  • Start Slicer and verify the module is present
  • Open the designer via the launcher (more info)
cd Slicer4-Superbuild/Slicer-build
slicer4 --designer
  • Open the module UI file (QTModules/MY_MODULE_NAME/Resources/UI/qSlicerMY_MODULE_NAMEModule.ui)

Qt Designer

  • How to set icons to widgets
    • In the icon property entry of the widget (Property Editor), select a resource file
      • Slicer4\QTModules\MY_MODULE_NAME\Resources\qSlicerMY_MODULE_NAMEModule.qrc
      • Slicer4\Libs\qMRMLWidgets\Resources\qMRMLWidget.qrc
      • Slicer4\Base\QTGUI\Resources\qSlicerBaseQTGUI.qrc
  • How to add an icon in a resource file
    • Add the icon in Slicer4/QTModules/MY_MODULE_NAME/Resources/Icon
    • Edit the resource file by adding the line
      • "<file>Icons/MyIcon.png</file>"

Qt Creator

Qt Creator is a cross-platform IDE that fully integrates Qt into the development of applications. Slicer CMake project is supported by Qt Creator, the following describes tips using Qt Creator.

  • Launch qtcreator through slicer to setup paths and paths to paths (this allows qtcreator to locate our custom designer plugins):
Slicer4 --launch /path/to/qtcreator
  • Configure and compile Slicer outside qtcreator first, from command line.
  • Open /path/to/Slicer-src/CMakeLists.txt in qtcreator, when prompted, choose the build directory where Slicer was configured and compiled in the previous step. (/path/to/Slicer-Superbuild/Slicer-build)
  • Turn off verbose make using this from Slicer-build:
cmake -D CMAKE_VERBOSE_MAKEFILE:BOOL=OFF .