Results 1 to 4 of 4

Thread: [PARTIALLY SOLVED] Error drawing?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2014
    Posts
    7
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Angry [PARTIALLY SOLVED] Error drawing?

    EDIT: For anyone getting this kind of error, override the paintEvent(QPaintEvent*) method..
    EDIT 2: The painting is happening as many times as something is drawn in the screen, aint there a way for this to happen only once without adding some bool in there?
    Hey all, I've got a project going where I'm trying to learn about clipping regions and painting.
    However, I'm stuck.
    The code presented below shows the clipped widget. Now, when I try to paint a red line on the borders of the clipped widget, it will, no error thrown, not even try to paint, or am I missing something?

    Qt Code:
    1. Cargador::Cargador(QWidget *parent) : QWidget(parent,Qt::FramelessWindowHint), ui(new Ui::Cargador) {
    2. ui->setupUi(this);
    3. resize(500,255);
    4. QRegion esquina;
    5. QRegion circulo;
    6. QRegion region(0,0,width(),height(),QRegion::Rectangle);
    7. // SUPERIOR IZQUIERDO
    8. circulo = QRegion(0,0,50,50,QRegion::Ellipse); // Circulo hardcodeado
    9. esquina = QRegion(0,0,25,25,QRegion::Rectangle); // Cuadrado de un cuarto del circulo
    10. region = region.subtracted(esquina.subtracted(circulo));
    11. // INFERIOR DERECHO
    12. circulo = QRegion(width()-50,height()-50,50,50,QRegion::Ellipse);
    13. esquina = QRegion(width()-25,height()-25,25,25,QRegion::Rectangle);
    14. region = region.subtracted(esquina.subtracted(circulo));
    15. setMask(region);
    16. QPixmap logo(":/Cargador/Imagenes/Logo.png",0,Qt::AutoColor);
    17. // qDebug() << logo;
    18. ui->lblLogo->setPixmap(logo);
    19. ui->lblLogo->show();
    20. // Labels transparentes
    21. ui->label->setAttribute(Qt::WA_TranslucentBackground);
    22. ui->label_2->setAttribute(Qt::WA_TranslucentBackground);
    23. ui->lblCargando->setAttribute(Qt::WA_TranslucentBackground);
    24. ui->lblLogo->setAttribute(Qt::WA_TranslucentBackground);
    25. // Borde en negro.
    26. QPainter decorador(this);
    27. //QPolygon poligono;
    28. QPen linea;
    29. zona.addRegion(region);
    30. linea.setWidth(8);
    31. linea.setColor(Qt::red);
    32. decorador.setPen(linea);
    33.  
    34. decorador.drawPath(zona);
    35.  
    36.  
    37.  
    38. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by QNewbie; 7th June 2014 at 03:06. Reason: Not that solved

Similar Threads

  1. arm + drawing
    By raghavendraningoji in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 31st December 2011, 16:57
  2. Exported PDF Drawing Error in Adobe Reader
    By BettaUseYoNikes in forum Qwt
    Replies: 0
    Last Post: 15th November 2011, 16:58
  3. Qt Drawing
    By Talguy in forum Newbie
    Replies: 4
    Last Post: 12th January 2011, 04:14
  4. error for drawing a line on mainwindow.
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 1
    Last Post: 6th February 2009, 07:15
  5. Drawing an arc.
    By munna in forum Qt Programming
    Replies: 6
    Last Post: 13th June 2006, 05:36

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.