c++ - Creating Graphics Tiles Using QVector(Basics Before QCache) -
i trying upgrade seismic graph viewer use tile graphics rendering. unfamiliar process attempt create simple example below. reason why need use either qvector or qcache(i'm using qvector right simplicity) save ram , tiles needed created on fly. i'm not entirely sure if you're able i'm trying below, creates array of bitmaps, makes them items, , tries add them scene. there twelve errors when program compiles, none of directly refer code made in mainwindow.cpp.
the errors either this
c:\qt\qt5.9.1\5.9.1\mingw53_32\include\qtcore\qvector.h:713: error: use of deleted function 'qgraphicspixmapitem& qgraphicspixmapitem::operator=(const qgraphicspixmapitem&)' thing changing being location of error (different header files)
or this
c:\qt\qt5.9.1\5.9.1\mingw53_32\include\qtwidgets\qgraphicsitem.h:861: error: 'qgraphicspixmapitem::qgraphicspixmapitem(const qgraphicspixmapitem&)' private q_disable_copy(qgraphicspixmapitem) in qgraphicsitem.h header file
the code produces doesn't compile due these errors popping in header files
int count; qvector<qbitmap> bitmaparraytiles; qvector<qgraphicspixmapitem> pixmapitemsarray; qgraphicspixmapitem currentitem; qbitmap currentbitmap; qgraphicsscene *scene = new qgraphicsscene(); for(count = 0; count < 4; count++) { currentbitmap = qbitmap(150,150); qpainter painter(¤tbitmap); qpen pen(qt::black); // explicit painter.setpen(pen); drawstuff(painter); bitmaparraytiles.insert(0, currentbitmap); currentitem.setpixmap(bitmaparraytiles[count]); pixmapitemsarray.insert(count, currentitem); scene->additem(¤titem); currentitem.maptoscene((count*150)+150, (count*150)+150); } ui->tileview->setscene(scene); ^
i have not changed header files manually i'm not entirely sure why getting these errors.
using pointers , tears
int count; qgraphicsscene *scene = new qgraphicsscene(0, 0, 150*4, 150*4); qvector<qbitmap*> bitmaparraytiles; qvector<qgraphicspixmapitem*> bitmapitemsarray; qgraphicspixmapitem* currentitem; qbitmap *currentbitmap; const qbitmap* currentbitmapconstpointer = currentbitmap; for(count = 0; count < 4; count++) { currentbitmap = new qbitmap(150,150); qpainter painter(currentbitmap); qpen pen(qt::black); // explicit painter.setpen(pen); drawstuff(painter); bitmaparraytiles.insert(count, currentbitmap); currentitem = new qgraphicspixmapitem(*bitmaparraytiles[count]); bitmapitemsarray.insert(count, currentitem); //pixmapitemsarray.insert(count, currentitem); scene->additem(bitmapitemsarray[count]); bitmapitemsarray[count]->setpos((count*150)+150, (count*150)+150); } ui->tileview->setscene(scene);
wiki
Comments
Post a Comment