Important: Please read the Qt Code of Conduct -

Trying to make Toolbar Corners curved, and make it semi-tranparent.

  • So I've got a toolbar that I'm adding to a widget.

    I create the toolbar thus:

        QApplication a(argc, argv);
        QPixmap p("C:\\Users\\amonra\\Documents\\Astrophotography\\NGC 7789 Caroline's Rose or Herschel's Spiral Cluster\\NGC7789 Edited large.png");
        DSSImageWidget w(p);
        DEditStars editor;
        QObject::connect(&w, &DSSImageWidget::Image_mousePressEvent, &editor, &DEditStars::mousePressEvent);
        QToolBar t(&w);
        QIcon dragRect("C:/Users/amonra/Documents/GitHub/DSS/DeepSkyStacker/Buttons/ButtonSelect_Up.bmp");
        t.addAction(dragRect, "", &editor, &DEditStars::dragButtonPressed);
        //t.setFixedSize(50, 50);
        t.setIconSize(QSize(48, 48));
        t.adjustSize();                                          // Work around bug with initial size of toolbar
        t.setWindowOpacity(0.5);                   // Make it semi-transparent
        int radius = t.size().width() / 2;           // Add curvey-corners
        QString styleSheet(QString("border-radius: %1").arg(radius));
        return a.exec();

    Trouble is the toolbar remains stubbornly rectangular, and 100% opaque :(


  • Lifetime Qt Champion

    @Perdrix said in Trying to make Toolbar Corners curved, and make it semi-tranparent.:

    QString styleSheet(QString("border-radius: %1").arg(radius));


    QString styleSheet(QString("border-radius: %1px").arg(radius));

  • A good thought and a bug well spotted! But sadly makes no difference:

    What I want is for the toolbar to look like this:


    But what I'm getting is this:


    Thanks, David

Log in to reply