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. Trying to make Toolbar Corners curved, and make it semi-tranparent.
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 310 Views
  • 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.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by
    #1

    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

    jsulmJ 1 Reply Last reply
    0
    • PerdrixP Perdrix

      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

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • PerdrixP Offline
        PerdrixP Offline
        Perdrix
        wrote on last edited by Perdrix
        #3

        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

        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