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. draw a Rectangle and bind it to QHLayout
Forum Updated to NodeBB v4.3 + New Features

draw a Rectangle and bind it to QHLayout

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 631 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.
  • A Offline
    A Offline
    alvinNew
    wrote on last edited by alvinNew
    #1

    Want to create a Rectangle and add widget to HLayout.
    In the end, it appears a circle in a box. How to get rid of the circle?

    QPixmap pm(100,100);
     pm.fill();
    
     QPainter p(&pm);
     p.setRenderHint(QPainter::Antialiasing,true);
     QPen pen(Qt::red, 1);
     p.setPen(pen);
     p.drawEllipse(0,0,80,80);
     QLabel* l = new QLabel;
     l->setPixmap(pm);
    
    
    Hlayout = new QHBoxLayout();
    Hlayout->addWidget(l);
    Hlayout->addWidget(stationlabel);
    
    p3c0P 1 Reply Last reply
    0
    • A alvinNew

      Want to create a Rectangle and add widget to HLayout.
      In the end, it appears a circle in a box. How to get rid of the circle?

      QPixmap pm(100,100);
       pm.fill();
      
       QPainter p(&pm);
       p.setRenderHint(QPainter::Antialiasing,true);
       QPen pen(Qt::red, 1);
       p.setPen(pen);
       p.drawEllipse(0,0,80,80);
       QLabel* l = new QLabel;
       l->setPixmap(pm);
      
      
      Hlayout = new QHBoxLayout();
      Hlayout->addWidget(l);
      Hlayout->addWidget(stationlabel);
      
      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @alvinNew Because you have used drawEllipse :)
      To draw rectangle use one of the drawRect method.

      157

      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