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. Get coordinates of dicom image by clicking anywhere on image in Qt
Forum Updated to NodeBB v4.3 + New Features

Get coordinates of dicom image by clicking anywhere on image in Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
23 Posts 5 Posters 2.9k 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.
  • P pvirk

    Screenshot (5).png

    I did this, but do not understand what is wrong in it.
    Do I need any header file?

    KroMignonK Offline
    KroMignonK Offline
    KroMignon
    wrote on last edited by
    #11

    @pvirk said in Get coordinates of dicom image by clicking anywhere on image in Qt:

    Do I need any header file?

    At least you must include the definition of QVTKWidget ==> maybe #include <QVTKWidget> or #include <QVTKWidget.h> ?

    It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

    1 Reply Last reply
    1
    • P pvirk

      Screenshot (5).png

      I did this, but do not understand what is wrong in it.
      Do I need any header file?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #12

      @pvirk Sorry, it needs to be

      class MyWidget : public QVTKWidget
      {
      protected:
          void mousePressEvent(QMouseEvent * event) ;
      }
      

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #13

        You are just mixing unrelated stuff.

        @jsulm provided you with the minimal class definition to get started.

        If you don't know how to do subclassing, then please, start by going through basic C++ tutorials before going further. You'll save yourself a lot of trouble.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        2
        • P Offline
          P Offline
          pvirk
          wrote on last edited by
          #14

          Okay. I will check C++ tutorials. Thank you so much everyone.

          1 Reply Last reply
          0
          • P Offline
            P Offline
            pvirk
            wrote on last edited by
            #15

            Hello,
            I have tried example to understand mousepressevent in QWidget.
            But I am facing some problem, when I use it in my code.
            I used one QVTKWidget to check coordinates with mousepressevent, and it worked. But when I use that same QVTKWIdget to load dicom data using vtkRenderWindow and interactor, it shows following errors. Here "matDisplay" is class I created for mousepressevent.

            1. Error C2039 'SetRenderWindow': is not a member of 'matDisplay'
            2. Error C2039 'GetInteractor': is not a member of 'matDisplay'

            I need Render Window and Interactor to render dicom images.

            So, how can I use mousepressevent in QVTKWidget?

            Please help and thanks in advance.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #16

              What is matDisplay ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #17

                Hi
                Can you show your exact code for matDisplay ?

                It should have those functions
                https://github.com/Kitware/VTK/blob/master/GUISupport/Qt/QVTKWidget.h

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  pvirk
                  wrote on last edited by
                  #18

                  Hello,
                  'matDisplay' is class i created for mousepressevent.
                  Screenshot (9).png Screenshot (8).png

                  then I used
                  QObject::connect(ui->qvtkWidget_3, SIGNAL(sendMousePosition(QPoint&)), this, SLOT(showMousePosition(QPoint&))); in my other .cpp file.

                  This thing works. Here I used subclass QWidget. But if I use QVTKWidget subclass, then build succeeded but then my program crashes.
                  But when I used this qvtkwidget_3 to get my dicom data, then shows me those errors.
                  Anyone has any idea about it?

                  mrjjM 1 Reply Last reply
                  0
                  • P pvirk

                    Hello,
                    'matDisplay' is class i created for mousepressevent.
                    Screenshot (9).png Screenshot (8).png

                    then I used
                    QObject::connect(ui->qvtkWidget_3, SIGNAL(sendMousePosition(QPoint&)), this, SLOT(showMousePosition(QPoint&))); in my other .cpp file.

                    This thing works. Here I used subclass QWidget. But if I use QVTKWidget subclass, then build succeeded but then my program crashes.
                    But when I used this qvtkwidget_3 to get my dicom data, then shows me those errors.
                    Anyone has any idea about it?

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

                    @pvirk
                    Hi
                    It has to inherit from QVTKWidget
                    as else it wont be right for the other classes as the errors shows:

                    Error C2039 'SetRenderWindow': is not a member of 'matDisplay'
                    Error C2039 'GetInteractor': is not a member of 'matDisplay'

                    This is correct as a QWidget does not have them. It comes from
                    QVTKWidget.

                    You have to use that QVTKWidget find out why it crashes.
                    I would guess you might forgot
                    to call
                    : QVTKWidget(parent) and maybe had QWidget(parent) from before.
                    so that the QVTKWidget was not ok setup. = crash

                    1 Reply Last reply
                    1
                    • P Offline
                      P Offline
                      pvirk
                      wrote on last edited by
                      #20

                      Hello,
                      I changed it to :QVTKWidget in both my .h and .cpp files of matDisplay class.
                      The reason for crashing was, In .ui file the qvtkwidget was not promoted to QVTKWidget.h file. I promoted to it and now there is no crashing.
                      But now the problem is I cannot use my matDisplay.h also as promoted class in .ui file. Because of that I cannot get coordinates of that widget.
                      How can I use both my QVTKWidget.h and matDisplay.h as promoted classes for qvtkwidget in .ui file?
                      I double-checked both of them in promoted widget option, but still it is only promoted to qvtkwidget.h only?
                      Screenshot (12).png

                      1 Reply Last reply
                      0
                      • mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #21

                        HI
                        you can not promote a widget to 2 different widgets.
                        That is not possible but would be cool if it could work :)
                        You can have 2 widgets but im not sure why you want that.

                        From the code, matDisplay is your version of QVTKWidget so
                        you should place a QWidget and promote that to matDisplay.

                        And it then contains your extra code for mousePress and all of QVTKWidget

                        1 Reply Last reply
                        1
                        • P Offline
                          P Offline
                          pvirk
                          wrote on last edited by
                          #22

                          I tried this way.
                          I used QWidget for my matDisplay class and promoted to matDisplay.
                          But when I use that same QWidget in my code to load image, It shows those same errors.
                          Error C2039 'SetRenderWindow': is not a member of 'matDisplay'
                          Error C2039 'GetInteractor': is not a member of 'matDisplay'

                          (because it is promoted to only matDisplay and not to QVTKWidget)

                          I need only one widget where i can load dicom image (which are connected to render window and interactor in my code) and use that same widget to get coordinates of that dicom image.

                          Sorry I tried all ways, but don't understand how to achieve these both things using only one widget.
                          Kindly please help me.

                          1 Reply Last reply
                          0
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #23

                            Inherit matWidget from QVTKWidget.

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            1

                            • Login

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