Results 1 to 4 of 4

Thread: QGraphicsScene - Adding graphics into it from 3rd party library

  1. #1
    Join Date
    Jun 2009
    Location
    India
    Posts
    143
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QGraphicsScene - Adding graphics into it from 3rd party library

    Hello all,

    We are working on QGraphicsScene and all the graphics to it is added as items.

    And we get some other graphics data from the 3rd party library also and we need to insert the same into the graphics scene.

    3rd party provides two options on getting its graphics data

    1) It will draw the graphics if we provide the window ID to its classes. But QGraphicsScene doesn't have winID,only QGraphicsView is having WinID

    (or)

    2) It provides a bitmap where we can read and convert as pixmap and add as item to Graphics scene . By using the second option the cpu load is more.

    Please advise how can we achieve this with the first method (or) best way of bringing the graphics into it.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsScene - Adding graphics into it from 3rd party library

    In both cases you end up with a bitmap of the item hence you can prerender all the bitmaps outside Graphics View (e.g creating a fake window that is never shown) and then import them into the framework as QGraphicsPixmapItem instances. The beauty of Graphics View is the ability to transform the view and I doubt you'll get that possibility with method 1 of the external framework. Of course all depends on your particular usecase.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jun 2009
    Location
    India
    Posts
    143
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsScene - Adding graphics into it from 3rd party library

    Quote Originally Posted by wysota View Post
    In both cases you end up with a bitmap of the item hence you can prerender all the bitmaps outside Graphics View (e.g creating a fake window that is never shown) and then import them into the framework as QGraphicsPixmapItem instances. The beauty of Graphics View is the ability to transform the view and I doubt you'll get that possibility with method 1 of the external framework. Of course all depends on your particular usecase.
    Dear Wysota,

    Thank you for your reply..

    I have referred your sample code below from this forum and i tried to insert the graphics from 3rd party library what i am using (using graphics view winID) . The Graphics is of 32bit Radar.

    Upon insert the radar is inserted to the window. Graphics Items are always on top of the radar. Is there some way i can change the graphics item as overlay and underlay.

    Please advise.
    Qt Code:
    1. #include <QtGui>
    2. #include <QPropertyAnimation>
    3. #include <QDebug>
    4.  
    5. class RectItem : public QObject, public QGraphicsRectItem {
    6. Q_OBJECT
    7. Q_PROPERTY(QPointF pos READ pos WRITE setPos)
    8. public:
    9. RectItem(const QRectF &rect, const QPen &pen, const QBrush &brush) : QObject(), QGraphicsRectItem(rect){
    10. setPen(pen);
    11. setBrush(brush);
    12. }
    13. };
    14.  
    15. #include "main.moc"
    16.  
    17. int main(int argc, char **argv){
    18. QApplication app(argc, argv);
    19. view.setAttribute(Qt::WA_TranslucentBackground);
    20. view.viewport()->setAttribute(Qt::WA_TranslucentBackground);
    21. QGraphicsScene scene(QRectF(0,0,1000,800));
    22. view.setScene(&scene);
    23. RectItem *rect = new RectItem(QRectF(0,0,200,100), QPen(QColor(255,0,0,0)),QColor(0,0,255,127) ); //Qt::red Qt::blue
    24. scene.addItem(rect);
    25. //rect->setOpacity(0.5);
    26. //rect->setZValue(9);
    27. RectItem *rect1 = new RectItem(QRectF(0,0,200,100), QPen(QColor(255,0,0,0)),QColor(255,0,0,255) ); //Qt::red Qt::blue
    28. scene.addItem(rect1);
    29. QPropertyAnimation *anim = new QPropertyAnimation(rect, "pos");
    30. anim->setDuration(50000);
    31. anim->setStartValue(scene.sceneRect().topLeft());
    32. anim->setEndValue(scene.sceneRect().bottomRight());
    33. anim->start();
    34. QPropertyAnimation *anim1 = new QPropertyAnimation(rect1, "pos");
    35. anim1->setDuration(50000);
    36. anim1->setStartValue(scene.sceneRect().topRight());
    37. anim1->setEndValue(scene.sceneRect().bottomLeft());
    38. anim1->start();
    39.  
    40. qDebug() << "In Code \n" ;
    41. view.show();
    42. return app.exec();
    43. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsScene - Adding graphics into it from 3rd party library

    I don't see how this code is relevant to anything you are doing...
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. My 3rd party library RPATH problem (Linux)
    By jezze_h in forum Installation and Deployment
    Replies: 3
    Last Post: 8th September 2011, 12:11
  2. Adding 3rd Party framework path in pro file
    By munna in forum Qt Programming
    Replies: 4
    Last Post: 9th November 2009, 10:42
  3. Replies: 5
    Last Post: 17th February 2009, 04:35
  4. Adding Rectangular overlay on graphics view
    By forrestfsu in forum Qt Programming
    Replies: 10
    Last Post: 21st November 2006, 19:42
  5. Building a third party library
    By munna in forum General Programming
    Replies: 1
    Last Post: 6th October 2006, 20:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.