draw a Rectangle and bind it to QHLayout



  • 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);

  • Moderators

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.