Results 1 to 6 of 6

Thread: Qt Graphics View and Web View

  1. #1
    Join Date
    Jul 2012
    Location
    UK
    Posts
    17
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qt Graphics View and Web View

    Dear All,

    I have a C++ Qt desktop application. I this application there are lots of QGraphicsItem which are shown in QGraphicsView. Those items animate uses QPropertyAnimation and user can change the properties of animation.

    Now I want to load this application in browser, so that multiple user can access the application remotely. Could you please give me some idea how can I do that with minimal code change or development?

    Thank you very much.

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt Graphics View and Web View

    you cant do it simply.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Jul 2012
    Location
    UK
    Posts
    17
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt Graphics View and Web View

    Just wanted to write a working code. What I want is that I want to load this in web-browser. Please give me your suggestion how to do that. Any working solution or pointer to the materials would be great. Thanks


    Qt Code:
    1. // main file: Creating scene, view and a circle item. Adding the circle to scene and calling the animation funstion.
    2.  
    3. scene = new QGraphicsScene (this);
    4. ui->testView->setScene(scene); // testView is object of QGraphicsView
    5.  
    6. CircleItem *circle = new CircleItem ();
    7. scene->addItem(circle);
    8. circle->animate();
    9.  
    10.  
    11. // CircleItem.h : Creating custom item which is basically a circle.
    12.  
    13. class CircleItem : public QObject, public QGraphicsItem
    14. {
    15. Q_OBJECT
    16. Q_PROPERTY (qreal scale READ scale WRITE setScale)
    17.  
    18. private:
    19. qreal _radius;
    20. qreal _scale;
    21. QPropertyAnimation *_anim;
    22.  
    23. public:
    24. CircleItem (QGraphicsItem *parent = 0);
    25. ~CircleItem ()
    26. {
    27. }
    28.  
    29. QRectF boundingRect () const;
    30. void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
    31.  
    32. void animate ();
    33. };
    34.  
    35.  
    36.  
    37. // CircleItem.cpp : The scale of the circle is being animated.
    38.  
    39. CircleItem::CircleItem (QGraphicsItem *parent)
    40. {
    41. _radius = 5.0;
    42. _scale = 3.0;
    43. }
    44.  
    45. QRectF CircleItem::boundingRect() const
    46. {
    47. double rect = _radius * _scale;
    48. return QRectF (-rect, -rect, 2 * rect, 2 * rect);
    49. }
    50.  
    51.  
    52. void CircleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
    53. {
    54.  
    55. QRectF rect ( -_radius, -_radius, 2 * _radius, 2 * _radius);
    56. painter->setRenderHint(QPainter::Antialiasing);
    57. painter->setPen (QPen (Qt::cyan, 2, Qt::SolidLine, Qt::RoundCap));
    58. painter->drawEllipse (rect);
    59.  
    60. }
    61.  
    62. // Repeatedly animating the scale.
    63.  
    64. void CircleItem::animate ()
    65. {
    66. _anim = new QPropertyAnimation (this, "scale");
    67. _anim->setEasingCurve (QEasingCurve::Linear);
    68. _anim->setDuration (1000);
    69. _anim->setStartValue (0);
    70. _anim->setEndValue (_scale);
    71.  
    72. _anim->setLoopCount (-1);
    73. _anim->start(QAbstractAnimation::DeleteWhenStopped);
    74. }
    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: Qt Graphics View and Web View

    You need to implement a web browser plugin and deploy it (along with Qt) on every computer you want to be able to launch the program. Of course each browser instance will have its own instance of the program, completely unrelated to others.
    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.


  5. The following user says thank you to wysota for this useful post:

    saifulkhan (18th November 2012)

  6. #5
    Join Date
    Jul 2012
    Location
    UK
    Posts
    17
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt Graphics View and Web View

    Is there any way in Qt to save the scene animation in a .png file?

  7. #6
    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: Qt Graphics View and Web View

    Qt can only save a series of png files, you'll have to assemble MNG from them on your own.
    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. graphics view architecture
    By qtcentreforum in forum Newbie
    Replies: 1
    Last Post: 15th February 2011, 12:25
  2. Graphics View : too many lines
    By natnan in forum Qt Programming
    Replies: 6
    Last Post: 28th January 2010, 11:15
  3. Scaling too much on a graphics view
    By natnan in forum Qt Programming
    Replies: 5
    Last Post: 15th September 2009, 12:48
  4. Graphics View and the Pixmap
    By spawn9997 in forum Qt Programming
    Replies: 2
    Last Post: 26th June 2009, 22:12
  5. Graphics View Queries
    By linuxdev in forum Qt Programming
    Replies: 13
    Last Post: 7th January 2009, 09:44

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.