3
QPushButton {    
    border: 2px solid red;
    height:24px;
    width:100px;
    border-top-left-radius: 50px;
    border-bottom-left-radius: 50px;
    border-top-right-radius: 0px;
    border-bottom-right-radius: 0px; 
}

which gives me rounded one side and flat on other side like this
enter image description here

I am looking to have a inward curve on one side and flat on other side like plano concave like this is there a way to achieve this
enter image description here

Rubina
  • 123
  • 1
  • 17

1 Answers1

5

I think a better approach here is to subclass the QPushButton and reimplement the paintEvent. Something like this

void PushButton::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);

    // Define pen
    QPen pen;
    pen.setWidth(4);

    // Draw outer cover
    pen.setColor(Qt::black);
    painter.setPen(pen);
    painter.setBrush(QColor(Qt::gray));
    painter.drawRect(this->rect());

    // Draw Inward arc
    pen.setWidth(2);
    painter.setPen(pen);
    painter.setBrush(QColor(Qt::white));

    int x = this->rect().x() - this->rect().width()/2;
    int y = this->rect().y();
    int w = this->rect().width();
    int h = this->rect().height();
    QRectF rectangle(x,y,w,h);
    painter.drawRoundedRect(rectangle,w,h);

}

Keep in mind this is just an example, you should take other things into considerations like the size of widget and how much angle should be the inward cure and everything else.

This is how it looks; I have programmed assuming its a the size of widget is always a square

KernelPanic
  • 2,328
  • 7
  • 47
  • 90
Gurushant
  • 952
  • 6
  • 23