Results 1 to 17 of 17

Thread: graphics view slow

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2009
    Posts
    38
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: graphics view slow

    this is funny reply.



    find something in between. will not achieve the desired speed!

    scroll by user is nonsense, have you play any game with scroll bar? unbelievable

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

    Default Re: graphics view slow

    Quote Originally Posted by dognzhe View Post
    scroll by user is nonsense, have you play any game with scroll bar? unbelievable
    Who said anything about the user? I meant you as a programmer.

    The fact that you don't understand what I said doesn't mean it is funny. If you design your application correctly you will achieve everything you want without problems. If you misdesign, you'll be running into problems on every step like it is happening now.
    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
    May 2009
    Posts
    38
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation Re: graphics view slow

    my logic is very simple, there is timer, when time out do all the drawing


    any one can help??????

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

    Default Re: graphics view slow

    You're not listening. The problem is very unlikely to be drawing. If you have doubts about it, take a profiler and find the bottleneck.
    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. #5
    Join Date
    May 2009
    Posts
    38
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation Re: graphics view slow

    Qt Code:
    1. #include "Tank.h"
    2.  
    3. Tank::Tank(QObject *parent,QGraphicsScene *scene)
    4. : QObject(parent), QGraphicsItem(0,scene)
    5. {
    6. tankDirection=dRight;
    7. tankUp = new QPixmap(":/CannonBattle/Resources/tank up.jpg");
    8. tankDown= new QPixmap(":/CannonBattle/Resources/tank down.jpg");
    9. tankRight =new QPixmap(":/CannonBattle/Resources/tank right.jpg");
    10. tankLeft = new QPixmap(":/CannonBattle/Resources/tank left.jpg");
    11. if(tankUp->isNull() && tankDown->isNull() && tankRight->isNull()){
    12. emit error(QString("tank image load fails"));
    13. }
    14. /*
    15.  
    16.   label.setText("dongzhe adfasd fasdfsdafsadfasdfasd");
    17.   //label.setMovie(movie);
    18.  mo=this->scene()->addWidget(&label);
    19.  mo->setPos(50,50);
    20.  */
    21.  
    22. this->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
    23.  
    24. }
    25.  
    26. Tank::~Tank()
    27. {
    28.  
    29. }
    30.  
    31. QPixmap* Tank::getImage() const{
    32.  
    33. if(tankDirection==dRight){
    34. return tankRight;
    35. }else if(tankDirection== dLeft){
    36. return tankLeft;
    37. }else if(tankDirection== dUp){
    38. return tankUp;
    39. }else{
    40. return tankDown;
    41. }
    42.  
    43. }
    44.  
    45. QRectF Tank::boundingRect() const{
    46.  
    47. //increase the boudingRect to get rid of marks
    48. return QRectF(getImage()->rect().x(),getImage()->rect().y(),getImage()->rect().width(),getImage()->rect().height()+2);
    49. //return getImage()->rect();
    50. }
    51.  
    52. void Tank::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){
    53.  
    54. painter->drawPixmap(QPoint(0,0),*getImage());
    55. //painter->drawImage(QPoint(0,0),QImage(":/CannonBattle/Resources/explose.gif"));
    56.  
    57.  
    58.  
    59. }
    60.  
    61.  
    62. int Tank::type() const {
    63.  
    64. return TANK_TYPE;
    65. }
    66.  
    67. [/QTCLASS]
    68.  
    69.  
    70. here is move tank
    71.  
    72. [QTCLASS]
    73. void CannonField::tankMove(){
    74. #if _DEBUG
    75. int a;
    76. int b;
    77. timeTemp.start();
    78. //timeTemp =QTime::currentTime();
    79.  
    80. #endif
    81.  
    82. QPointF oldPoint(mainTank->pos());
    83. tankCurrentY = mainTank->pos().y();
    84. tankCurrentX= mainTank->pos().x();
    85. if(mainTank->tankDirection==mainTank->dUp){
    86. mainTank->setPos(tankCurrentX, tankCurrentY-tankSpeed);
    87. }
    88.  
    89. if(mainTank->tankDirection==mainTank->dDown){
    90. mainTank->setPos(tankCurrentX, tankCurrentY+tankSpeed);
    91. }
    92.  
    93. if(mainTank->tankDirection==mainTank->dLeft){
    94. mainTank->setPos(tankCurrentX-tankSpeed,tankCurrentY);
    95. }
    96.  
    97. if(mainTank->tankDirection==mainTank->dRight){
    98. mainTank->setPos(tankCurrentX+tankSpeed,tankCurrentY);
    99. }
    100.  
    101. tankCurrentY = mainTank->pos().y();
    102. tankCurrentX= mainTank->pos().x();
    103.  
    104.  
    105. if (tankCurrentX <0 || tankCurrentY<0 || tankCurrentX > (scene.width()-mainTank->boundingRect().width()) || tankCurrentY > (scene.height()-mainTank->boundingRect().height())) {
    106. mainTank->setPos(oldPoint);
    107. }
    108.  
    109. QList<QGraphicsItem *> collisions = mainTank->collidingItems(Qt::IntersectsItemBoundingRect);
    110. if(!collisions.isEmpty()){
    111.  
    112. QListIterator<QGraphicsItem *> it(collisions);
    113. while(it.hasNext()){
    114. temp= it.next();
    115. if(temp->type()==TARGET_TYPE){
    116. mainTank->setPos(oldPoint);
    117. }
    118. }
    119.  
    120. }
    121.  
    122.  
    123. //graphicsView.centerOn(mainTank);
    124. graphicsView.ensureVisible(mainTank,graphicsView.rect().width()/3,graphicsView.rect().height()/3);
    125. #if _DEBUG
    126. //for(int i=0;i<1000000;i++)
    127. //{i++;}
    128. //b=QTime::currentTime().msecsTo(timeTemp);
    129. a= timeTemp.elapsed();
    130. qDebug("%d\n",a);
    131. #endif
    132. }
    To copy to clipboard, switch view to plain text mode 


    I don;'t know what to do ...
    Last edited by wysota; 8th May 2009 at 06:39.

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

    Default Re: graphics view slow

    Please take a profiler and find the bottle neck in your application. Now you're just shooting blind.
    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.


  7. #7
    Join Date
    May 2009
    Posts
    38
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: graphics view slow

    Quote Originally Posted by wysota View Post
    Please take a profiler and find the bottle neck in your application. Now you're just shooting blind.
    where can i get profiler? is that free? can you give me a link????

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

    Default Re: graphics view slow

    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.


  9. #9
    Join Date
    May 2009
    Posts
    38
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: graphics view slow

    man, i can 't find the free one... i am using VS2005 with qt.

    do you know any free one for downlaod?

  10. #10
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

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

    Default Re: graphics view slow

    Quote Originally Posted by dognzhe View Post
    man, i can 't find the free one... i am using VS2005 with qt.
    Consider switching to a Free compiler then.
    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 Panning ,zooming
    By linuxdev in forum Qt Programming
    Replies: 3
    Last Post: 29th December 2008, 07:17
  2. Replies: 4
    Last Post: 5th August 2008, 19:55
  3. Graphics View Event Propagation
    By pherthyl in forum Qt Programming
    Replies: 10
    Last Post: 3rd July 2008, 10:39
  4. Graphics view display problem.
    By kiranraj in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2007, 07:08
  5. Adding Rectangular overlay on graphics view
    By forrestfsu in forum Qt Programming
    Replies: 10
    Last Post: 21st November 2006, 19:42

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.