Results 1 to 20 of 22

Thread: Is that any problem in my this function?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2009
    Location
    Guangzhou,China
    Posts
    89
    Thanks
    17
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Is that any problem in my this function?

    I'm sure that the data in the vector is OK. but I can not draw line.

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Is that any problem in my this function?

    can you show us code where you use this method?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Is that any problem in my this function?

    what is the size of avgPoints?

  4. #4
    Join Date
    Feb 2009
    Location
    Guangzhou,China
    Posts
    89
    Thanks
    17
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Is that any problem in my this function?

    Qt Code:
    1. void GenePlotter::refreshPixmap()
    2. {
    3. pixmap = QPixmap(size());
    4. pixmap.fill(this, 0, 0);
    5.  
    6. QPainter painter(&pixmap);
    7. painter.initFrom(this);
    8. drawGrid(&painter); // This line works perfectly good
    9.  
    10. if(couter!=0)
    11. drawPlotterLine(&painter); // here can't draw line
    12.  
    13. update();
    14. }
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Feb 2009
    Location
    Guangzhou,China
    Posts
    89
    Thanks
    17
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Is that any problem in my this function?

    Quote Originally Posted by talk2amulya View Post
    what is the size of avgPoints?
    In fact, the size will increase when the app runs, for example the size will increase from 1 to 100. And I will call the function to redraw the pixmap for 100 times.

  6. #6
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Is that any problem in my this function?

    stupid question, but maybe couter == 0?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  7. #7
    Join Date
    Feb 2009
    Location
    Guangzhou,China
    Posts
    89
    Thanks
    17
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Is that any problem in my this function?

    Quote Originally Posted by spirit View Post
    stupid question, but maybe couter == 0?
    No, the couter will increase. I make it draw only couter >0 ;

    Qt Code:
    1. // In the construtor function
    2. connect(oneStepButton,SIGNAL(clicked()),this,SLOT(oneStep()));
    3. connect(runAllButton,SIGNAL(clicked()),this,SLOT(runAll()));
    To copy to clipboard, switch view to plain text mode 

  8. #8
    Join Date
    Feb 2009
    Location
    Guangzhou,China
    Posts
    89
    Thanks
    17
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Is that any problem in my this function?

    Qt Code:
    1. // perform one generaion evolution and update the points of the plotter
    2. void GenePlotter::execOnce()
    3. {
    4. geneGroup.performEvolution();
    5. QPointF point;
    6. point.setX(couter);
    7. point.setY(((geneGroup.getGroup())+GeneGroup::popSize)->getfitness());
    8. bestPoints.push_back(point);
    9.  
    10. point.setY(geneGroup.getAvg());
    11. // x are the same of these two point.
    12. avgPoints.push_back(point);
    13.  
    14. refreshPixmap();
    15. }
    16.  
    17.  
    18. void GenePlotter::oneStep()
    19. {
    20. ++couter;
    21. if(couter<generation)
    22. {
    23. execOnce();
    24. }
    25. }
    26.  
    27.  
    28. void GenePlotter::runAll()
    29. {
    30. settingButton->setEnabled(false);
    31. oneStepButton->setEnabled(false);
    32. runAllButton->setEnabled(false);
    33. qApp->processEvents();
    34. if(couter==0)
    35. ++couter;
    36.  
    37. while(couter<generation)
    38. {
    39. ++couter;
    40. execOnce();
    41. repaint();
    42. }
    43. settingButton->setEnabled(true);
    44. oneStepButton->setEnabled(true);
    45. runAllButton->setEnabled(true);
    46.  
    47. }
    To copy to clipboard, switch view to plain text mode 

    More code

  9. #9
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Is that any problem in my this function?

    if you do this
    Qt Code:
    1. void GenePlotter::refreshPixmap()
    2. {
    3. pixmap = QPixmap(size());
    4. pixmap.fill(this, 0, 0);
    5.  
    6. QPainter painter(&pixmap);
    7. painter.initFrom(this);
    8. drawGrid(&painter); // This line works perfectly good
    9. drawPlotterLine(&painter); // here can't draw line
    10.  
    11. update();
    12. }
    To copy to clipboard, switch view to plain text mode 
    is something changed?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  10. #10
    Join Date
    Feb 2009
    Location
    Guangzhou,China
    Posts
    89
    Thanks
    17
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Is that any problem in my this function?

    to #9

    Fail, the same

Similar Threads

  1. Replies: 3
    Last Post: 12th March 2012, 01:45
  2. subclassed const function problem
    By qtneuling in forum Newbie
    Replies: 8
    Last Post: 22nd June 2008, 02:52
  3. Function confusion
    By KShots in forum General Programming
    Replies: 3
    Last Post: 26th June 2007, 21:56
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. K&R's strcpy function - problem with pointers
    By jamadagni in forum General Programming
    Replies: 7
    Last Post: 8th January 2006, 15:16

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.