qt - How to work with QGraphicsScene::addPixmap when it only accepts const QPixmap? -
I would like to display mainwindow.h mainwindow.cpp And after that the complainant has stated that whatever I did wrong: only accept This method does not make much sense to me, if I want to create an image viewer, for example, and during the runtime, I definitely have to load different images Using this problem has become sick, thanks for any advice, can you give me a little bit light if there is any vision on philosophical reasons, how do people in QT make these methods Are Try Some advice: There is no need to allocate the keys to the pile (new experiment). Use: Then you do not need to call when you call, just to clarify : Constness has nothing to do with error. QGraphicsScene through some QImage My code is very straightforward:
QImage * sourceImage; QGraphicsView * imageView; QGraphicsScene * imageScene;
imageScene = new QGraphicsScene; ImageView = New QGraphicsView; ImageView-> SetScene (imageScene); SourceImage = new QImage; SourceImage.load (": / targetimage.png"); ImageScene.addPixmap (QPixmap :: fromImage (sourceImage)); const QPixmap as argument, and I QImage < / Code> const QPixmap is not allowed, because accept const QImage within QPixmap :: fromImage , such as Const hell QImage sourceImage < / Code>, and how can I do that a const QImage ? const ?
imageScene.addPixmap (QPixmap :: fromImage ( * Source image));
QImage source image; QPixmap :: fromImage
Comments
Post a Comment