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. want to create 3 triangle and widget them in QHVBoxLayout()
Qt 6.11 is out! See what's new in the release blog

want to create 3 triangle and widget them in QHVBoxLayout()

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 536 Views 2 Watching
  • 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.
  • H Offline
    H Offline
    houmingc
    wrote on last edited by
    #1

    why is my code not working?
    want to create 3 triangle and widget them in QHVBoxLayout().

    QRectF rect= QRectF(0,0,100,100);
    
    QPainterPath path;
    path.moveTo(rect.topLeft(),rect.left());
    path.lineTo(rect.bottomLeft());
    path.lineTo(rect.topRight());
    
    QPainter painter;
    painter.setPen(Qt:: NoPen);
    painter.fillPath(path, QBrush(QColor("blue")) );
    
    1 Reply Last reply
    0
    • Chris KawaC Online
      Chris KawaC Online
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Your painter doesn't have anything to paint on. If the above code is inside an overriden paintEventthen it should be something like QPainter painter(this);.

      1 Reply Last reply
      0

      • Login

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