Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. why setPen didn't work?

why setPen didn't work?

Scheduled Pinned Locked Moved Unsolved General and Desktop
setpenblueblackaddpolygon
2 Posts 2 Posters 665 Views
  • 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.
  • stackprogramerS Offline
    stackprogramerS Offline
    stackprogramer
    wrote on last edited by stackprogramer
    #1

    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
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      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
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved