Results 1 to 4 of 4

Thread: problem with Qpainter being too slow (Maemo5)

  1. #1
    Join Date
    May 2010
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Maemo/MeeGo

    Default problem with Qpainter being too slow (Maemo5)

    Hi,

    I have this problem with QPainter. I'm making widget that has many lines and dots. Problem is that it's realy slow.

    I trying to make scrollable widget that's in QScrollArea. Here is a example picture how it looks on Maemo5:



    In mainwindow.cpp I have scrollArea and I put my widget in to it by:
    Qt Code:
    1. PainterWidget *mypainterWidget = new PainterWidget(ui->scrollArea);
    2. ui->verticalLayout->addWidget(mypainterWidget);
    To copy to clipboard, switch view to plain text mode 

    In PainterWidget I have paintEvent like this:
    Qt Code:
    1. void PainterWidget::paintEvent(QPaintEvent *)
    2. {
    3.  
    4. QPainter painter2(this);
    5. painter2.setRenderHint(QPainter::Antialiasing, true);
    6. painter2.setPen(QPen(Qt::white, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
    7. QPainter painter3(this);
    8. painter3.setRenderHint(QPainter::Antialiasing, true);
    9. painter3.setPen(QPen(QColor(198,0,0,255), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
    10.  
    11.  
    12. for(int i=0 ; i<30;i++){
    13.  
    14. if(i>0){
    15. path.moveTo(col[i-1]+5, row[i-1]+5);
    16. path.cubicTo(col[i-1]+5, row[i-1]+5, ((col[i-1]+col[i])/2), ((row[i-1]+row[i])/2), col[i], row[i]+5);
    17.  
    18. painter3.drawPath(path);
    19.  
    20. }
    21.  
    22. }
    23.  
    24.  
    25. for(int i=0 ; i<30;i++){
    26.  
    27. painter.drawEllipse(col[i], row[i], 10, 10);
    28.  
    29. }
    30.  
    31. }
    To copy to clipboard, switch view to plain text mode 



    It's highly possible that I'm just doin something wrong here. Can someone help me with these information.

    How can I make this to work faster?
    Last edited by asdf; 26th May 2010 at 18:05.

  2. #2
    Join Date
    May 2010
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Maemo/MeeGo

    Default Re: problem with Qpainter being too slow (Maemo5)

    Should I use some other kind of method?

    Is it possible to draw image with QPainter and then set it into ScrollArea?

    I have realy tried to make this work for a couple of days now but nothing works well..

  3. #3
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: problem with Qpainter being too slow (Maemo5)

    Probably this is not the best advice, and I don't know if it will speed things up (never programmed to Maemo5), but try to draw into QImage and then display that QImage.

  4. #4
    Join Date
    May 2010
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Maemo/MeeGo

    Smile Re: problem with Qpainter being too slow (Maemo5)

    Finally I found a solution.

    painter2.setRenderHint(QPainter::Antialiasing, true); is too heavy to use. Now it woks fine.

Similar Threads

  1. Replies: 1
    Last Post: 24th January 2010, 11:15
  2. Qt 2.3.10 QPainter problem on arm
    By yagabey in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 7th October 2008, 12:29
  3. QT 4.4.0 Upgrade QPainter Problem
    By ChrisReath in forum Qt Programming
    Replies: 4
    Last Post: 13th May 2008, 15:25
  4. Slow problem QTableView
    By skuda in forum Qt Programming
    Replies: 6
    Last Post: 26th February 2008, 12:19
  5. Problem with QScrollview and QPainter
    By saida in forum Qt Programming
    Replies: 14
    Last Post: 7th March 2006, 05:14

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.