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. ASSERT: "!item->d_ptr->itemDiscovered" in file graphicsview\qgraphicsscenebsptreeindex.cpp, line 343
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
4 Posts 1 Posters 2.4k Views
  • 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 Offline
    L Offline
    LCL_data
    wrote on last edited by
    #1

    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
    0
    • L Offline
      L Offline
      LCL_data
      wrote on last edited by
      #2

      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
      0
      • L Offline
        L Offline
        LCL_data
        wrote on last edited by
        #3

        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
        0
        • L Offline
          L Offline
          LCL_data
          wrote on last edited by
          #4

          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
          0

          • Login

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