Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/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.setOrientation(Qt::Vertical);
        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));
        t.setStyleSheet(styleSheet);
        w.setToolBar(&t);
        w.show();
        return a.exec();
    

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

    David


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

    Maybe

    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:

    5af3a8fc-b393-4ecc-b923-bbea03edf373-image.png

    But what I'm getting is this:

    11cdc82d-ec78-4600-8850-5594bd8bda04-image.png

    Thanks, David


Log in to reply