Having trouble drawing an image in Qt using QGraphicsScene -


  1. the code below loads image using qlabel. code uses: mylabel.setmask(pixmap.mask()); , works should. problem comes when try , load image using qgraphicsscene.

    #include <qapplication> #include <qlabel> #include <qtgui>  int main(int argc, char *argv[]) {    qapplication app(argc, argv);    qlabel mylabel;    qpixmap pixmap("/path/tomy/image.jpg");    mylabel.setpixmap(pixmap);    mylabel.setmask(pixmap.mask());     mylabel.show();     return app.exec(); } 
  2. in code attempting same above using qgraphicsscene. pixmap loaded properly, after not sure why program not working properly. because there no setmask() operation? or there operation missing needed make image visible?

    #include <qtglobal>   #if qt_version >= 0x050000    #include <qtwidgets> #else    #include <qtgui> #endif  int main(int argc, char *argv[])  {    qapplication a(argc, argv);    qpixmap pixmap("/path/tomy/image.jpg");    qgraphicspixmapitem item( pixmap);    qgraphicsscene* scene = new qgraphicsscene;    scene->additem(&item);    qgraphicsview view(scene);     view.show();     return a.exec(); } 


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

python 3.5 - Pyqtgraph string in x tick -