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. QGraphicsView class crashes the application
Forum Updated to NodeBB v4.3 + New Features

QGraphicsView class crashes the application

Scheduled Pinned Locked Moved General and Desktop
17 Posts 3 Posters 4.4k Views 1 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.
  • raven-worxR Offline
    raven-worxR Offline
    raven-worx
    Moderators
    wrote on last edited by
    #7

    where is this variable initialized? StationaryImageObject_

    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
    If you have a question please use the forum so others can benefit from the solution in the future

    1 Reply Last reply
    0
    • V Offline
      V Offline
      venkatesh
      wrote on last edited by
      #8

      Its initialised at the header in ImageRegistrationImplementation.h

      @

      private:

      listWidget listObject_;
      StationaryImageViewer StationaryImageObject_;
      MovingImageViewer MovingImageObject_;

      @

      1 Reply Last reply
      0
      • V Offline
        V Offline
        venkatesh
        wrote on last edited by
        #9

        I could understand the program crashes at the line

        @

        QVariant StationaryImageData_=StationaryImageQListItem_->data(Qt::UserRole);

        @

        But i don't know why

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

          Hi,

          Are you sure StationaryImageQListItem_ is valid ?

          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
          0
          • V Offline
            V Offline
            venkatesh
            wrote on last edited by
            #11

            Hi,
            I have used an object created from a class listWidget

            @
            listWidget listWidgetViewerObject;
            @

            to get the current item of the listWidget using

            @

            StationaryImageQListItem_ =listWidgetViewerObject.currentItem();
            

            @

            and used it in QVariant. I don't understand what's going wrong here

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

              Again, are you sure that StationaryImageQListItem_ is pointing to a valid item ?

              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
              0
              • V Offline
                V Offline
                venkatesh
                wrote on last edited by
                #13

                I tried to reimplement it in another way as

                listWidget.cpp

                @

                QString listWidget::ConvertMovingData_()
                {
                QVariant MovingImageData_=item(currentRow()+1)->data(Qt::UserRole);
                QString MovingData_=MovingImageData_.toString();
                QFileInfo MovingImageInfo_(MovingData_);
                QString MovingImageFilePath_= MovingImageInfo_.absoluteFilePath();
                return MovingImageFilePath_;

                }

                QString listWidget::ConvertStationaryData_()
                {
                QVariant StationaryImageData_=currentItem()->data(Qt::UserRole);
                QString StationaryData_=StationaryImageData_.toString();
                QFileInfo StationaryImageInfo_(StationaryData_);
                QString StationaryImageFilePath_= StationaryImageInfo_.absoluteFilePath();
                return StationaryImageFilePath_;

                }

                @

                listWidget.h

                @
                public slots:
                QString ConvertMovingData_();
                QString ConvertStationaryData_();
                @

                And i used it in

                movingimageviewer.cpp

                @

                void MovingImageViewer::setMovingImage_()
                {
                MovingImageScene_->removeItem(MovingImageViewItem_);
                MovingImageScene_->clear();
                QString MovingStringData=listWidgetMovingViewerObject.ConvertMovingData_();
                MovingImagePixmap_.load(MovingStringData);
                MovingImageViewItem_->setPixmap(MovingImagePixmap_);
                MovingImageScene_->addItem(MovingImageViewItem_);
                fitInView(MovingImageScene_->itemsBoundingRect(),Qt::IgnoreAspectRatio);
                setScene(MovingImageScene_);
                show();
                update();
                }
                @

                similarly in

                @

                void StationaryImageViewer::setStationaryImage_()
                {

                StationaryImageScene_->removeItem(StationaryImageViewItem_);
                StationaryImageScene_->clear();
                QString StationaryStringData= listWidgetStationaryObject.ConvertStationaryData_();
                StationaryImagePixmap_.load(StationaryStringData);
                StationaryImageViewItem_->setPixmap(StationaryImagePixmap_);
                StationaryImageScene_->addItem(StationaryImageViewItem_);
                fitInView(StationaryImageScene_->itemsBoundingRect(),Qt::IgnoreAspectRatio);
                setScene(StationaryImageScene_);
                show();
                update();
                

                }

                @

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  venkatesh
                  wrote on last edited by
                  #14

                  This is the crash report for this implementation

                  Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
                  0 com.yourcompany.ImageRegistration 0x0000000100055d4f listWidget::ConvertStationaryData_() + 31 (listWidget.cpp:58)
                  1 com.yourcompany.ImageRegistration 0x0000000100056a44 StationaryImageViewer::setStationaryImage_() + 68 (stationaryimageviewer.cpp:21)

                  which again corresponds to the @QVariant@ implementation

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

                    You still don't check whether the return value of currentItem() is valid

                    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
                    0
                    • V Offline
                      V Offline
                      venkatesh
                      wrote on last edited by
                      #16

                      Hi,

                      How can I check whether it is valid ?? I thought it should be valid, as I am just taking the data of the item which is clicked in listWidget. Is there a way to check In Qt, like catching an exception ? Or error

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

                        Just test if the pointer is null

                        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
                        0

                        • Login

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