Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    ASSERT: "!item->d_ptr->itemDiscovered" in file graphicsview\qgraphicsscenebsptreeindex.cpp, line 343

    General and Desktop
    1
    4
    2202
    Loading More Posts
    • 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.
    • L
      LCL_data last edited by

      I want to get the thumbnail from QGraphicsScene:
      @ QImage image;
      QPainter painter(&image);
      painter.setRenderHint(QPainter::Antialiasing);
      scene->render(&painter);
      image.save("scene.png");@

      scene->render throw the error and error detail is:
      @---------------------------
      Microsoft Visual C++ Debug Library

      Debug Error!

      Program: ...\PBMaker\Source\Trunk\PBMaker\PBMaker\Win32\Debug\PBMaker.exe
      Module: 5.0.1
      File: global\qglobal.cpp
      Line: 1951

      ASSERT: "!item->d_ptr->itemDiscovered" in file graphicsview\qgraphicsscenebsptreeindex.cpp, line 343

      (Press Retry to debug the application)

      Abort Retry Ignore

      @

      and my scene is :
      @ QGraphicsScene *scene = new QGraphicsScene();
      scene->setBackgroundBrush(Qt::white);
      scene->addWidget(page);
      scene->setSceneRect(0,0,mSceneSize.width(),mSceneSize.height());

          //add all areas
          QList<PBArea *> areas =  page->getArea();  
          int areaTotalNumber = areas.size();
          for ( int areaIndex = 0 ; areaIndex < areaTotalNumber ; areaIndex++ )
          {       
              scene->addItem(areas[areaIndex]);
          }@
      

      page inherts from QWidget , PBArea inherts from QGraphicsItem.

      a little strange to get this debug error. am i missing something ?

      1 Reply Last reply Reply Quote 0
      • L
        LCL_data last edited by

        and I test the scene->render again in a clear Qt project:
        @#include "qttest501.h"
        #include <QGraphicsScene>
        #include <QPainter>
        #include <QDesktopWidget>
        qtTest501::qtTest501(QWidget *parent)
        : QMainWindow(parent)
        {
        ui.setupUi(this);

        QGraphicsScene *scene = new QGraphicsScene();
        scene->addRect(QRectF(0, 0, 100, 200), QPen(Qt::black), QBrush(Qt::green));   
        
        QPixmap pixmap;
        QPainter painter(&pixmap);
        painter.setRenderHint(QPainter::Antialiasing);
        scene->render(&painter);
        painter.end();
        
        bool sceneRet =  pixmap.save("scene.png","png");
        
        pixmap = QPixmap::grabWindow(QApplication::desktop()->winId(),pos().x(),pos().y(),frameGeometry().width(),frameGeometry().height());
        bool pixmapRet =  pixmap.save("blog.png","png");
        

        }

        qtTest501::~qtTest501()
        {

        }
        @
        and sceneRet is false and pixmapRet is true... also strange..

        1 Reply Last reply Reply Quote 0
        • L
          LCL_data last edited by

          I modify
          @QPixmap pixmap;@
          to
          @QPixmap pixmap(130,130);@
          and sceneRet can return true and get the correct thunbnail.

          but for the ASSERT error still have even if i change
          @QImage image;@
          to
          @ QImage image(70,70,QImage::Format_ARGB32);@

          if i try to get the thumbnail from QGraphicsView, it success .

          STRANGE.

          1 Reply Last reply Reply Quote 0
          • L
            LCL_data last edited by

            I know why the Debug error pop-up:
            my scene 's size is 100100, but one of my item is position is 200105. change it back into the scene's size. debug error disappear.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post