私は、グラフィックス表示をタイルグラフィックスレンダリングを使用するようにアップグレードしようとしています。私はこのプロセスにはほとんど慣れていませんが、簡単な例を作成しようとする私の試みは以下の通りです。私がQVectorまたはQCacheのどちらかを使用する必要がある理由(私はQVectorを簡単にするために現在使用しています)は、RAMとそのタイルをオンザフライで作成する必要がありません。私はあなたが私が以下でやろうとしていることをすることができるかどうかは完全にはわかりませんが、本質的にはビットマップの配列を作成し、アイテムを作成してシーンに追加しようとします。このプログラムをコンパイルすると、12個のエラーがありますが、mainWindow.cppで作成したコードを直接参照するものはありません。QVectorを使用してグラフィックスタイルを作成する(QCache前の基本)
エラーがされているか、この
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&)' with the only thing changing being the location of the error (different header files)
またはこの
C:\Qt\Qt5.9.1\5.9.1\mingw53_32\include\QtWidgets\qgraphicsitem.h:861: error: 'QGraphicsPixmapItem::QGraphicsPixmapItem(const QGraphicsPixmapItem&)' is private Q_DISABLE_COPY(QGraphicsPixmapItem) which is in the qgraphicsitem.h header file
ヘッダファイルにポップアップによるこれらのエラーをコンパイルできない生成コード
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); // just to be 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);
^
私は手動でヘッダファイルを変更していないので、なぜこれらのエラーが出るのか全然わからない。
はQObjectはコピーできません。 Qt4のやり方は、オブジェクトの代わりにポインタを使うことでした。 – drescherjm
https://stackoverflow.com/questions/19854371/repeating-q-disable-copy-in-qobject-derived-classes – drescherjm
https://stackoverflow.com/questions/2652504/how-do-i-copy-object -in-qt – drescherjm