Difference between revisions of "Slicer3:Developers:Projects:QtSlicer/Tutorials/ModuleWriting"

From Slicer Wiki
Jump to: navigation, search
(Created page with '* Create the Module directory cd Slicer4 python Scripts/ModuleWizard.py MY_MODULE_NAME Note: on Windows ..\Slicer4-Superbuild\python-build\PCBuild\python.exe Scripts\ModuleWiz…')
 
Line 1: Line 1:
 +
= Initialization =
 
* Create the Module directory
 
* Create the Module directory
 
  cd Slicer4
 
  cd Slicer4
Line 11: Line 12:
 
  slicer4 --designer
 
  slicer4 --designer
 
*Open the module UI file (QTModules/MY_MODULE_NAME/Resources/UI/qSlicerMY_MODULE_NAMEModule.ui)
 
*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>"

Revision as of 01:46, 12 January 2011

Home < Slicer3:Developers:Projects:QtSlicer < Tutorials < ModuleWriting

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
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>"