Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Error while initializing the Object in Qt
Qt 6.11 is out! See what's new in the release blog

Error while initializing the Object in Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 4 Posters 3.5k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi

    Are you sure you are using the right types?
    The first error seems to say cannot make an A into B.
    SlideWidget versus SlideControllerWidget

    But for test :
    if you make a

    in qMRMLSliceWidget.cpp

    void test () {
    qMRMLSliceControllerWidget test;
    }

    will it accept it ?

    Ofc with the right include etc.

    if still no. Then you might have a circular include where
    qMRMLSliceWidget includes qMRMLSliceControllerWidget and reverse.

    1 Reply Last reply
    2
    • M Offline
      M Offline
      Meera Hadid
      wrote on last edited by Meera Hadid
      #3

      I tried using test() method:
      Screenshot (302).png
      I have a doubt even in test() method we are just declaring the object right, we are not initializing. My doubt is how to initialize the object.
      For accessing the widgets in qMRMLSliceControllerWidget I will have to create its object right? or is there any other method.

      JonBJ mrjjM 2 Replies Last reply
      0
      • M Meera Hadid

        I tried using test() method:
        Screenshot (302).png
        I have a doubt even in test() method we are just declaring the object right, we are not initializing. My doubt is how to initialize the object.
        For accessing the widgets in qMRMLSliceControllerWidget I will have to create its object right? or is there any other method.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #4

        @Meera-Hadid said in Error while initializing the Object in Qt:

        I tried using test() method

        The error message indicates that, whatever code you have written, you are attempting to access a variable named test when you say you declared a method named test().

        1 Reply Last reply
        2
        • M Offline
          M Offline
          Meera Hadid
          wrote on last edited by
          #5

          Screenshot (304).png
          using test object i tried calling the spinBox in qMRMLSliceControllerWidget
          code:

          qMRMLSliceControllerWidgetPrivate* qMRMLSliceWidget::test() {
              qMRMLSliceControllerWidgetPrivate* test;
              return test;
          }
          
          test_obj = qMRMLSliceWidget::test();
            this->ControllerLayout = new QVBoxLayout(q);
            this->ControllerLayout->setSpacing(2);
            QMargins cmargins = this->ControllerLayout->contentsMargins();
            cmargins.setTop(0);
            cmargins.setBottom(0);
            cmargins.setLeft(0);
            cmargins.setRight(0);
            this->ControllerLayout->setContentsMargins(cmargins);
            
            this->ControllerLayout->addWidget(test_obj->spinBox);
            q->setLayout(this->ControllerLayout);
          
          mrjjM 1 Reply Last reply
          0
          • M Meera Hadid

            I tried using test() method:
            Screenshot (302).png
            I have a doubt even in test() method we are just declaring the object right, we are not initializing. My doubt is how to initialize the object.
            For accessing the widgets in qMRMLSliceControllerWidget I will have to create its object right? or is there any other method.

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #6

            @Meera-Hadid

            Hi

            we should not name both object and function test. sorry my bad, too little coffe :)

            I meant

            void test () {
            qMRMLSliceControllerWidget mySC;
            }
            

            it was just to see if it does know the type without errors.

            Well its just a local variable so it is initialized as such. ( even there is no new )

            It seems it does know the type and does not complain about it ? , correct ?

            So this seems to be fine so you should be able to create
            a qMRMLSliceWidget in qMRMLSliceWidget.

            I think what ever the q is you are giving it
            new qMRMLSliceControllerWidget(q)) <<<< i think its not what it wants

            hence the error in the picture

            1 Reply Last reply
            1
            • M Meera Hadid

              Screenshot (304).png
              using test object i tried calling the spinBox in qMRMLSliceControllerWidget
              code:

              qMRMLSliceControllerWidgetPrivate* qMRMLSliceWidget::test() {
                  qMRMLSliceControllerWidgetPrivate* test;
                  return test;
              }
              
              test_obj = qMRMLSliceWidget::test();
                this->ControllerLayout = new QVBoxLayout(q);
                this->ControllerLayout->setSpacing(2);
                QMargins cmargins = this->ControllerLayout->contentsMargins();
                cmargins.setTop(0);
                cmargins.setBottom(0);
                cmargins.setLeft(0);
                cmargins.setRight(0);
                this->ControllerLayout->setContentsMargins(cmargins);
                
                this->ControllerLayout->addWidget(test_obj->spinBox);
                q->setLayout(this->ControllerLayout);
              
              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #7

              @Meera-Hadid
              Hi
              the code you just posted will crash :)
              Its dangling pointer.

              qMRMLSliceControllerWidgetPrivate* qMRMLSliceWidget::test() {
              qMRMLSliceControllerWidgetPrivate* test; <<<<< dangling pointer !
              return test;
              }

              so that will not work 100%

              it must be
              qMRMLSliceControllerWidgetPrivate* qMRMLSliceWidget::test() {
              qMRMLSliceControllerWidgetPrivate* test = new qMRMLSliceControllerWidgetPrivate( what ever it wants)
              return test;
              }

              ps. why you go from qMRMLSliceControllerWidget to
              qMRMLSliceControllerWidgetPrivate `?
              the private type seems its called that as one should not use it outside class ?

              1 Reply Last reply
              2
              • M Offline
                M Offline
                Meera Hadid
                wrote on last edited by Meera Hadid
                #8

                Basically the spinBox is defined in qMRMLSliceControllerWidgetPrivate but it is a public variable. For better understanding

                qMRMLSliceControllerWidget_p.h:

                #ifndef __qMRMLSliceControllerWidget_p_h
                #define __qMRMLSliceControllerWidget_p_h
                // CTK includes
                #include <ctkPimpl.h>
                #include <ctkVTKObject.h>
                
                // qMRML includes
                #include "qMRMLSliceControllerWidget.h"
                #include "qMRMLViewControllerBar_p.h"
                #include "ui_qMRMLSliceControllerWidget.h"
                
                // MRMLLogic includes
                #include <vtkMRMLSliceLogic.h>
                
                // VTK includes
                #include <vtkAlgorithmOutput.h>
                #include <vtkCollection.h>
                #include <vtkImageData.h>
                #include <vtkSmartPointer.h>
                #include <vtkWeakPointer.h>
                
                class ctkSignalMapper;
                class ctkDoubleSpinBox;
                class ctkVTKSliceView;
                class QSpinBox;
                class qMRMLSliderWidget;
                class vtkMRMLSliceNode;
                class vtkObject;
                class vtkMRMLSegmentationDisplayNode;
                
                //-----------------------------------------------------------------------------
                struct QMRML_WIDGETS_EXPORT qMRMLOrientation
                {
                  QString Prefix;
                  QString ToolTip;
                };
                
                //-----------------------------------------------------------------------------
                class QMRML_WIDGETS_EXPORT qMRMLSliceControllerWidgetPrivate
                  : public qMRMLViewControllerBarPrivate
                  , public Ui_qMRMLSliceControllerWidget
                {
                  Q_OBJECT
                  QVTK_OBJECT
                  Q_DECLARE_PUBLIC(qMRMLSliceControllerWidget);
                
                public:
                  typedef qMRMLSliceControllerWidgetPrivate Self;
                  typedef qMRMLViewControllerBarPrivate Superclass;
                  qMRMLSliceControllerWidgetPrivate(qMRMLSliceControllerWidget& object);
                  ~qMRMLSliceControllerWidgetPrivate() override;
                
                  void init() override;
                  void setColor(QColor color) override;
                
                  void setupLinkedOptionsMenu();
                  void setupReformatOptionsMenu();
                  void setupLightboxMenu();
                  void setupCompositingMenu();
                  void setupSliceSpacingMenu();
                  void setupSliceModelMenu();
                  void setupSegmentationMenu();
                  void setupLabelMapMenu();
                  void setupMoreOptionsMenu();
                  void setupOrientationMarkerMenu();
                  void setupRulerMenu();
                
                  qMRMLOrientation mrmlOrientation(const QString& name);
                
                  vtkSmartPointer<vtkCollection> saveNodesForUndo(const QString& nodeTypes);
                
                  void enableLayerWidgets();
                
                  vtkMRMLSliceLogic* compositeNodeLogic(vtkMRMLSliceCompositeNode* node);
                  vtkMRMLSliceLogic* sliceNodeLogic(vtkMRMLSliceNode* node);
                
                  void setForegroundInterpolation(vtkMRMLSliceLogic* logic, bool interpolate);
                  void setBackgroundInterpolation(vtkMRMLSliceLogic* logic, bool interpolate);
                
                  /// Create a list of orientation containing the regular presets and also
                  /// the "Reformat" string if sliceToRAS is different one of the preset.
                  static void updateSliceOrientationSelector(
                      vtkMRMLSliceNode* sliceNode, QComboBox *sliceOrientationSelector);
                
                  //static qMRMLSliceControllerWidgetPrivate* Get();
                
                public slots:
                  /// Update widget state when the scene is modified
                  void updateFromMRMLScene();
                
                  /// Update widget state using the associated MRML slice node
                  void updateWidgetFromMRMLSliceNode();
                
                  /// Update widget state using the associated MRML slice composite node
                  void updateWidgetFromMRMLSliceCompositeNode();
                
                  /// Called after a foreground layer volume node is selected
                  /// using the associated qMRMLNodeComboBox
                  void onForegroundLayerNodeSelected(vtkMRMLNode* node);
                
                  /// Called after a background layer volume node is selected
                  /// using the associated qMRMLNodeComboBox
                  void onBackgroundLayerNodeSelected(vtkMRMLNode* node);
                
                  /// Called after a label layer volume node is selected
                  /// using the associated qMRMLNodeComboBox
                  void onLabelMapNodeSelected(vtkMRMLNode* node);
                
                  /// Called after a segmentation node is selected in the combobox
                  void onSegmentationNodeSelected(vtkMRMLNode* node);
                
                  /// Called after the currently selected segmentation node's display
                  /// option is modified
                  void onSegmentationNodeDisplayModifiedEvent(vtkObject* nodeObject);
                  /// Called when segment visibility is changed from the segment combobox
                  void onSegmentVisibilitySelectionChanged(QStringList selectedSegmentIDs);
                  /// Update segmentation outline/fill button
                  void updateSegmentationOutlineFillButton();
                  /// Utility function to get the display node of the current segmentation
                  vtkMRMLSegmentationDisplayNode* currentSegmentationDisplayNode();
                
                  void updateFromForegroundDisplayNode(vtkObject* displayNode);
                  void updateFromBackgroundDisplayNode(vtkObject* displayNode);
                
                  void updateFromForegroundVolumeNode(vtkObject* volumeNode);
                  void updateFromBackgroundVolumeNode(vtkObject* volumeNode);
                
                  /// Called after the SliceLogic is modified
                  void onSliceLogicModifiedEvent();
                
                  void applyCustomLightbox();
                
                protected:
                  void setupPopupUi() override;
                  virtual void setMRMLSliceNodeInternal(vtkMRMLSliceNode* sliceNode);
                  void setMRMLSliceCompositeNodeInternal(vtkMRMLSliceCompositeNode* sliceComposite);
                
                public:
                  vtkMRMLSliceNode*                   MRMLSliceNode;
                  vtkMRMLSliceCompositeNode*          MRMLSliceCompositeNode;
                  vtkSmartPointer<vtkMRMLSliceLogic>  SliceLogic;
                  vtkCollection*                      SliceLogics;
                  vtkWeakPointer<vtkAlgorithmOutput>  ImageDataConnection;
                  QHash<QString, qMRMLOrientation>    SliceOrientationToDescription;
                  QString                             SliceViewName;
                  QButtonGroup*                       ControllerButtonGroup;
                
                  QToolButton*                        FitToWindowToolButton;
                  qMRMLSliderWidget*                  SliceOffsetSlider;
                 ctkDoubleSpinBox*                   spinBox;
                  double                              LastLabelMapOpacity;
                  double                              LastForegroundOpacity;
                  double                              LastBackgroundOpacity;
                  QMenu*                              LightboxMenu;
                  QMenu*                              CompositingMenu;
                  QMenu*                              SliceSpacingMenu;
                  QMenu*                              SliceModelMenu;
                  QMenu*                              SegmentationMenu;
                  QMenu*                              LabelMapMenu;
                  QMenu*                              OrientationMarkerMenu;
                  QMenu*                              RulerMenu;
                
                  ctkDoubleSpinBox*                   SliceSpacingSpinBox;
                  ctkDoubleSpinBox*                   SliceFOVSpinBox;
                  QSpinBox*                           LightBoxRowsSpinBox;
                  QSpinBox*                           LightBoxColumnsSpinBox;
                
                  ctkDoubleSpinBox*                   SliceModelFOVXSpinBox;
                  ctkDoubleSpinBox*                   SliceModelFOVYSpinBox;
                
                  ctkDoubleSpinBox*                   SliceModelOriginXSpinBox;
                  ctkDoubleSpinBox*                   SliceModelOriginYSpinBox;
                
                  QSpinBox*                           SliceModelDimensionXSpinBox;
                  QSpinBox*                           SliceModelDimensionYSpinBox;
                
                  QSize                               ViewSize;
                
                  ctkSignalMapper*                    OrientationMarkerTypesMapper;
                  ctkSignalMapper*                    OrientationMarkerSizesMapper;
                
                  ctkSignalMapper*                    RulerTypesMapper;
                  ctkSignalMapper*                    RulerColorMapper;
                };
                
                #endif
                
                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  Meera Hadid
                  wrote on last edited by Meera Hadid
                  #9

                  qMRMLSliceControllerWidget.cxx:

                  void qMRMLSliceControllerWidgetPrivate::init()
                  {
                    Q_Q(qMRMLSliceControllerWidget);
                  
                    this->Superclass::init();
                    this->FitToWindowToolButton = new QToolButton(q);
                    this->FitToWindowToolButton->setObjectName("FitToWindowToolButton");
                    //this->FitToWindowToolButton->setToolTip(tr("Adjust the Slice Viewer's field of view to match the extent of lowest non-None volume layer (bg, then fg, then label)."));
                    //QIcon fitToWindowIcon(":/Icons/SlicesFitToWindow.png");
                    //this->FitToWindowToolButton->setIcon(fitToWindowIcon);
                    this->FitToWindowToolButton->setAutoRaise(true);
                    this->FitToWindowToolButton->setDefaultAction(this->actionFit_to_window);
                    this->FitToWindowToolButton->setFixedSize(15, 15);
                    this->BarLayout->insertWidget(2, this->FitToWindowToolButton);
                    //Hide FitToWindowToolButton from the Barlayout
                    this->FitToWindowToolButton->hide();
                  
                  
                    this->SliceOffsetSlider = new qMRMLSliderWidget(q);
                    this->SliceOffsetSlider->setObjectName("SliceOffsetSlider");
                    this->SliceOffsetSlider->setTracking(false);
                    this->SliceOffsetSlider->setToolTip(qMRMLSliceControllerWidget::tr("Slice distance from RAS origin"));
                    this->SliceOffsetSlider->setQuantity("length");
                    this->SliceOffsetSlider->setUnitAwareProperties(
                      qMRMLSliderWidget::Suffix|qMRMLSliderWidget::Precision|qMRMLSliderWidget::Scaling);
                    this->SliceOffsetSlider->spinBox()->setDecimalsOption(
                      ctkDoubleSpinBox::DecimalsByShortcuts |
                      ctkDoubleSpinBox::DecimalsByKey |
                      ctkDoubleSpinBox::DecimalsAsMin );
                  
                    //this->SliceOffsetSlider->spinBox()->setParent(this->PopupWidget);
                    spinBox = this->SliceOffsetSlider->spinBox();
                    spinBox->setFrame(false);
                    spinBox->spinBox()->setButtonSymbols(QAbstractSpinBox::NoButtons);
                    spinBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
                    int targetHeight = spinBox->parentWidget()->layout()->sizeHint().height();//setSizeConstraint(QLayout::SetMinimumSize);
                    int fontHeight = spinBox->fontMetrics().height();
                    qreal heightRatio = static_cast<qreal>(targetHeight - 2) / fontHeight;
                    if (heightRatio  < 1.)
                      {
                      QFont stretchedFont(spinBox->font());
                      stretchedFont.setPointSizeF(stretchedFont.pointSizeF() * heightRatio);
                      spinBox->setFont(stretchedFont);
                      }
                  
                    // Connect Slice offset slider
                    this->connect(this->SliceOffsetSlider, SIGNAL(valueChanged(double)),
                                  q, SLOT(setSliceOffsetValue(double)), Qt::QueuedConnection);
                    this->connect(this->SliceOffsetSlider, SIGNAL(valueIsChanging(double)),
                                  q, SLOT(trackSliceOffsetValue(double)), Qt::QueuedConnection);
                    this->connect(q, SIGNAL(mrmlSceneChanged(vtkMRMLScene*)),
                                  this->SliceOffsetSlider, SLOT(setMRMLScene(vtkMRMLScene*)));
                    this->BarLayout->addWidget(this->SliceOffsetSlider);
                    this->SliceOffsetSlider->hide();
                    this->BarLayout->addWidget(this->spinBox);
                  
                    //spinBox->hide();
                    // Move the spinbox in the popup instead of having it in the slider bar
                    //dynamic_cast<QGridLayout*>(this->PopupWidget->layout())->addWidget(
                    //  this->SliceOffsetSlider->spinBox(), 0, 0, 1, 2);
                  
                    // Hide all buttons by default
                    this->MoreButton->setChecked(false);
                  
                    vtkNew<vtkMRMLSliceLogic> defaultLogic;
                    q->setSliceLogic(defaultLogic.GetPointer());
                  
                    q->setSliceViewName("Red");
                  }
                  

                  i want to use this spinBox in qMRMLSliceWidget

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    Meera Hadid
                    wrote on last edited by
                    #10

                    and the qMRMLSliceControllerWidget constructor is

                    qMRMLSliceControllerWidgetPrivate::qMRMLSliceControllerWidgetPrivate(qMRMLSliceControllerWidget& object)
                      : Superclass(object)
                    {
                      this->SliceLogic = nullptr;
                      this->MRMLSliceNode = nullptr;
                      this->MRMLSliceCompositeNode = nullptr;
                      this->SliceLogics = nullptr;
                    
                      this->ControllerButtonGroup = nullptr;
                      qMRMLOrientation axialOrientation = {qMRMLSliceControllerWidget::tr("Axial:"), qMRMLSliceControllerWidget::tr("I <-----> S")};
                      qMRMLOrientation sagittalOrientation = {qMRMLSliceControllerWidget::tr("Sagittal:"), qMRMLSliceControllerWidget::tr("L <-----> R")};
                      qMRMLOrientation coronalOrientation = {qMRMLSliceControllerWidget::tr("Coronal:"), qMRMLSliceControllerWidget::tr("P <-----> A")};
                      qMRMLOrientation obliqueOrientation = {"", qMRMLSliceControllerWidget::tr("Oblique")};
                    
                      this->SliceOrientationToDescription["Axial"] = axialOrientation;
                      this->SliceOrientationToDescription["Sagittal"] = sagittalOrientation;
                      this->SliceOrientationToDescription["Coronal"] = coronalOrientation;
                      this->SliceOrientationToDescription["Reformat"] = obliqueOrientation;
                    
                      this->LastLabelMapOpacity = 1.;
                      this->LastForegroundOpacity = 1.;
                      this->LastBackgroundOpacity = 1.;
                    
                      this->FitToWindowToolButton = nullptr;
                      this->SliceOffsetSlider = nullptr;
                      this->spinBox = nullptr;
                      
                      this->LightboxMenu = nullptr;
                      this->CompositingMenu = nullptr;
                      this->SliceSpacingMenu = nullptr;
                      this->SliceModelMenu = nullptr;
                      this->SegmentationMenu = nullptr;
                      this->LabelMapMenu = nullptr;
                      this->OrientationMarkerMenu = nullptr;
                      this->RulerMenu = nullptr;
                    
                      this->SliceSpacingSpinBox = nullptr;
                      this->SliceFOVSpinBox = nullptr;
                      this->LightBoxRowsSpinBox = nullptr;
                      this->LightBoxColumnsSpinBox = nullptr;
                    
                      this->SliceModelFOVXSpinBox = nullptr;
                      this->SliceModelFOVYSpinBox = nullptr;
                    
                      this->SliceModelOriginXSpinBox = nullptr;
                      this->SliceModelOriginYSpinBox = nullptr;
                    
                      this->SliceModelDimensionXSpinBox = nullptr;
                      this->SliceModelDimensionYSpinBox = nullptr;
                    }
                    

                    i want to place this spinBox in qMRMLSliceWidget, is there any method for doing this?

                    mrjjM 1 Reply Last reply
                    0
                    • M Meera Hadid

                      and the qMRMLSliceControllerWidget constructor is

                      qMRMLSliceControllerWidgetPrivate::qMRMLSliceControllerWidgetPrivate(qMRMLSliceControllerWidget& object)
                        : Superclass(object)
                      {
                        this->SliceLogic = nullptr;
                        this->MRMLSliceNode = nullptr;
                        this->MRMLSliceCompositeNode = nullptr;
                        this->SliceLogics = nullptr;
                      
                        this->ControllerButtonGroup = nullptr;
                        qMRMLOrientation axialOrientation = {qMRMLSliceControllerWidget::tr("Axial:"), qMRMLSliceControllerWidget::tr("I <-----> S")};
                        qMRMLOrientation sagittalOrientation = {qMRMLSliceControllerWidget::tr("Sagittal:"), qMRMLSliceControllerWidget::tr("L <-----> R")};
                        qMRMLOrientation coronalOrientation = {qMRMLSliceControllerWidget::tr("Coronal:"), qMRMLSliceControllerWidget::tr("P <-----> A")};
                        qMRMLOrientation obliqueOrientation = {"", qMRMLSliceControllerWidget::tr("Oblique")};
                      
                        this->SliceOrientationToDescription["Axial"] = axialOrientation;
                        this->SliceOrientationToDescription["Sagittal"] = sagittalOrientation;
                        this->SliceOrientationToDescription["Coronal"] = coronalOrientation;
                        this->SliceOrientationToDescription["Reformat"] = obliqueOrientation;
                      
                        this->LastLabelMapOpacity = 1.;
                        this->LastForegroundOpacity = 1.;
                        this->LastBackgroundOpacity = 1.;
                      
                        this->FitToWindowToolButton = nullptr;
                        this->SliceOffsetSlider = nullptr;
                        this->spinBox = nullptr;
                        
                        this->LightboxMenu = nullptr;
                        this->CompositingMenu = nullptr;
                        this->SliceSpacingMenu = nullptr;
                        this->SliceModelMenu = nullptr;
                        this->SegmentationMenu = nullptr;
                        this->LabelMapMenu = nullptr;
                        this->OrientationMarkerMenu = nullptr;
                        this->RulerMenu = nullptr;
                      
                        this->SliceSpacingSpinBox = nullptr;
                        this->SliceFOVSpinBox = nullptr;
                        this->LightBoxRowsSpinBox = nullptr;
                        this->LightBoxColumnsSpinBox = nullptr;
                      
                        this->SliceModelFOVXSpinBox = nullptr;
                        this->SliceModelFOVYSpinBox = nullptr;
                      
                        this->SliceModelOriginXSpinBox = nullptr;
                        this->SliceModelOriginYSpinBox = nullptr;
                      
                        this->SliceModelDimensionXSpinBox = nullptr;
                        this->SliceModelDimensionYSpinBox = nullptr;
                      }
                      

                      i want to place this spinBox in qMRMLSliceWidget, is there any method for doing this?

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #11

                      @Meera-Hadid
                      Do you mean its
                      ctkDoubleSpinBox* spinBox; ?

                      well its public so i guess you can.

                      it sems to be allocated / assigned in
                      qMRMLSliceControllerWidgetPrivate::init()
                      ....
                      spinBox = this->SliceOffsetSlider->spinBox();

                      but im still not sure what that "q" is that it seems to use for constructor.

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        Meera Hadid
                        wrote on last edited by Meera Hadid
                        #12

                        I Have a QToolButton in the first UI I don't want to display it over there but the functionalities/actions of the button are initialized in the first.cxx file. So when I create an object of the first class in the second class and try adding the button in a widget of the second class does the button get transferred?

                        QToolButton code in qMRMLSLiceControllerWidget.cxx:

                        this->FitToWindowToolButton = new QToolButton(q);
                        this->FitToWindowToolButton->setObjectName("FitToWindowToolButton");
                        this->FitToWindowToolButton->setAutoRaise(true);
                        this->FitToWindowToolButton->setDefaultAction(this->actionFit_to_window);
                        this->FitToWindowToolButton->setFixedSize(15, 15);
                        
                        QObject::connect(this->actionFit_to_window, SIGNAL(triggered()),
                                       q, SLOT(fitSliceToBackground()));
                        

                        Object of qMRMLSLiceControllerWidget in qMRMLSliceWidget: initialization in qMRMLSliceWidget_p.h:

                        qMRMLSliceControllerWidget* scw;
                        

                        declaration in qMRMLSliceWidget.cxx:

                        scw = new qMRMLSliceControllerWidget(q);
                        

                        when I create an object like this in my App I don't know for what reason 0.00 is getting displayed
                        Screenshot (312).png

                        1 Reply Last reply
                        0
                        • C Offline
                          C Offline
                          Coleman Jeffrey
                          wrote on last edited by
                          #13

                          Thank you and everyone, I also had the same problem.
                          Thanks

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved