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
    #4

    i asked "where" not "when".
    Start your application with a debugger (e.g. QtCreator in debug mode) and it will show you the position in the code.

    --- 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
      #5

      Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
      0 com.yourcompany.ImageRegistration 0x0000000100056b3a StationaryImageViewer::setStationaryImage_() + 42 (stationaryimageviewer.cpp:18)
      1 com.yourcompany.ImageRegistration 0x0000000100058052 StationaryImageViewer::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) + 130 (moc_stationaryimageviewer.cpp:48)
      2 QtCore 0x0000000101b8d09e QMetaObject::activate(QObject*, QMetaObject const*, int, void**) + 1566
      3 QtGui 0x000000010134c3b1 QListWidget::itemDoubleClicked(QListWidgetItem*) + 49
      4 QtCore 0x0000000101b8d09e QMetaObject::activate(QObject*, QMetaObject const*, int, void**) + 1566
      5 QtGui 0x00000001012d90e9 QAbstractItemView::doubleClicked(QModelIndex const&) + 41
      6 QtGui 0x00000001012db205 QAbstractItemView::mouseDoubleClickEvent(QMouseEvent*) + 277
      7 QtGui 0x0000000100e34481 QWidget::event(QEvent*) + 2449
      8 QtGui 0x00000001011c60ac QFrame::event(QEvent*) + 44
      9 QtGui 0x00000001012526e7 QAbstractScrollArea::viewportEvent(QEvent*) + 23
      10 QtGui 0x00000001012e78cb QAbstractItemView::viewportEvent(QEvent*) + 427
      11 QtGui 0x0000000101254a70 QAbstractScrollAreaFilter::eventFilter(QObject*, QEvent*) + 48
      12 QtCore 0x0000000101b74687 QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) + 151
      13 QtGui 0x0000000100dd95be QApplicationPrivate::notify_helper(QObject*, QEvent*) + 142
      14 QtGui 0x0000000100de0190 QApplication::notify(QObject*, QEvent*) + 2384
      15 QtCore 0x0000000101b74bdc QCoreApplication::notifyInternal(QObject*, QEvent*) + 124
      16 QtGui 0x0000000100dddbdd QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) + 333
      17 QtGui 0x0000000100d8d6cb qt_mac_handleMouseEvent(NSEvent*, QEvent::Type, Qt::MouseButton, QWidget*, bool) + 763
      18 com.apple.AppKit 0x00007fff8b01c50e -[NSWindow sendEvent:] + 6853
      19 QtGui 0x0000000100d827d7 -[QCocoaWindow sendEvent:] + 87
      20 com.apple.AppKit 0x00007fff8b018644 -[NSApplication sendEvent:] + 5761
      21 QtGui 0x0000000100d87814 -[QNSApplication sendEvent:] + 84
      22 com.apple.AppKit 0x00007fff8af2e21a -[NSApplication run] + 636
      23 QtGui 0x0000000100d92680 QEventDispatcherMac::processEvents(QFlagsQEventLoop::ProcessEventsFlag) + 1824
      24 QtCore 0x0000000101b73af4 QEventLoop::processEvents(QFlagsQEventLoop::ProcessEventsFlag) + 68
      25 QtCore 0x0000000101b73ea4 QEventLoop::exec(QFlagsQEventLoop::ProcessEventsFlag) + 324
      26 QtCore 0x0000000101b7658c QCoreApplication::exec() + 188
      27 com.yourcompany.ImageRegistration 0x0000000100002375 main + 101 (main.cpp:12)
      28 com.yourcompany.ImageRegistration 0x00000001000022cd _start + 203
      29 com.yourcompany.ImageRegistration 0x0000000100002201 start + 33

      Thread 1:
      0 libsystem_kernel.dylib 0x00007fff92e3d6d6 __workq_kernreturn + 10
      1 libsystem_c.dylib 0x00007fff8a7c5f1c _pthread_workq_return + 25
      2 libsystem_c.dylib 0x00007fff8a7c5ce3 _pthread_wqthread + 412
      3 libsystem_c.dylib 0x00007fff8a7b0191 start_wqthread + 13

      Thread 2:: Dispatch queue: com.apple.libdispatch-manager
      0 libsystem_kernel.dylib 0x00007fff92e3dd16 kevent + 10
      1 libdispatch.dylib 0x00007fff93c60dea _dispatch_mgr_invoke + 883
      2 libdispatch.dylib 0x00007fff93c609ee _dispatch_mgr_thread + 54

      Thread 3:
      0 libsystem_kernel.dylib 0x00007fff92e3d6d6 __workq_kernreturn + 10
      1 libsystem_c.dylib 0x00007fff8a7c5f1c _pthread_workq_return + 25
      2 libsystem_c.dylib 0x00007fff8a7c5ce3 _pthread_wqthread + 412
      3 libsystem_c.dylib 0x00007fff8a7b0191 start_wqthread + 13

      Thread 4:
      0 libsystem_kernel.dylib 0x00007fff92e3d6d6 __workq_kernreturn + 10
      1 libsystem_c.dylib 0x00007fff8a7c5f1c _pthread_workq_return + 25
      2 libsystem_c.dylib 0x00007fff8a7c5ce3 _pthread_wqthread + 412
      3 libsystem_c.dylib 0x00007fff8a7b0191 start_wqthread + 13

      Thread 5:
      0 libsystem_kernel.dylib 0x00007fff92e3d6d6 __workq_kernreturn + 10
      1 libsystem_c.dylib 0x00007fff8a7c5f1c _pthread_workq_return + 25
      2 libsystem_c.dylib 0x00007fff8a7c5ce3 _pthread_wqthread + 412
      3 libsystem_c.dylib 0x00007fff8a7b0191 start_wqthread + 13

      Thread 6:
      0 libsystem_kernel.dylib 0x00007fff92e3d6d6 __workq_kernreturn + 10
      1 libsystem_c.dylib 0x00007fff8a7c5f1c _pthread_workq_return + 25
      2 libsystem_c.dylib 0x00007fff8a7c5ce3 _pthread_wqthread + 412
      3 libsystem_c.dylib 0x00007fff8a7b0191 start_wqthread + 13

      Thread 7:
      0 libsystem_kernel.dylib 0x00007fff92e3d6d6 __workq_kernreturn + 10
      1 libsystem_c.dylib 0x00007fff8a7c5f1c _pthread_workq_return + 25
      2 libsystem_c.dylib 0x00007fff8a7c5ce3 _pthread_wqthread + 412
      3 libsystem_c.dylib 0x00007fff8a7b0191 start_wqthread + 13

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

        I have posted the implementation again for clarity in lines

        @
        #include "stationaryimageviewer.h"
        #include"QtGui"
        #include"QFileInfo"
        #include"QVariant"
        #include"QString"

        StationaryImageViewer::StationaryImageViewer(QWidget *parent) :
        QGraphicsView(parent)
        {

        }

        void StationaryImageViewer::setStationaryImage_()
        {

        StationaryImageQListItem_ =listWidgetViewerObject.currentItem();
        QVariant StationaryImageData_=StationaryImageQListItem_->data(Qt::UserRole);
        QString StationaryData_=StationaryImageData_.toString();
        QFileInfo StationaryImageInfo_(StationaryData_);
        StationaryImageFilePath_= StationaryImageInfo_.absoluteFilePath();
        StationaryImagePixmap_.load(StationaryImageFilePath_);
        StationaryImageViewItem_->setPixmap(StationaryImagePixmap_);
        StationaryImageScene_->addItem(StationaryImageViewItem_);
        fitInView(StationaryImageScene_->itemsBoundingRect(),Qt::IgnoreAspectRatio);
        setScene(StationaryImageScene_);
        show();
        update();
        

        }
        @

        1 Reply Last reply
        0
        • 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