Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved why setPen didn't work?

    General and Desktop
    setpen blue black addpolygon
    2
    2
    544
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • stackprogramer
      stackprogramer last edited by stackprogramer

      hi, here is a part of my source,
      why despite changing color pen,my shape is created in only one color blue??
      i want to some line is blue,some line is black...

      
              myPolygon << QPointF(-100, -100) << QPointF(100, -100)
                        << QPointF(100, 100) ;
      
               setPen(QPen(Qt::black, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
      
                    path.addRect(0,0,200, 200);
                    myPolygon = path.toFillPolygon();
      
                   setPen(QPen(Qt::blue, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
      
                     path.setFillRule(Qt::OddEvenFill);
                    path.addRect(90,0,20,20);
                    path.addRect(0,90,20,20);
                    path.addRect(180,90,20,20);
                    myPolygon << QPointF(0, 0) << QPointF(40,0)
                              << QPointF(0, 40) ;
                    path.addPolygon( myPolygon);
      
      

      this is link image shape:
      http://www.mediafire.com/view/em34sbr026b555m/Qpenproblem.png#
      thanks for reply

      1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by mrjj

        Hi
        What are u calling setPen on?

        Paths do not store color and such information
        so Im not sure its possible to do with only 1 polygon.

        Maybe create a subclass of QGraphicsItem and paint it directly with
        qpainter::drawLine which supports colors very easy.

        http://www.bogotobogo.com/Qt/Qt5_QGraphicsView_QGraphicsScene_QGraphicsItems.php

        1 Reply Last reply Reply Quote 1
        • First post
          Last post