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. How is it possible to make rounded edges for QMainWindow?
Forum Updated to NodeBB v4.3 + New Features

How is it possible to make rounded edges for QMainWindow?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 4 Posters 9.2k Views 1 Watching
  • 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.
  • sepera_okeqS Offline
    sepera_okeqS Offline
    sepera_okeq
    wrote on last edited by sepera_okeq
    #1

    Hi everyone, how is it possible to make rounded edges for QMainWindow?
    I use QSS, specifically:

    border: 1px solid black; 
    border-radius: 10px;
    

    I want to do something like this:
    5790d9e8-4356-40f3-836c-5a18a5d8cbc2-image.png
    But it turns out like this:
    e41b80bf-8e46-4d37-b33c-13cbcb8e9eb9-image.png

    Why is that? And how can this be done?
    Thank you in advance!

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      You can look here
      https://doc.qt.io/qt-5/qtwidgets-widgets-shapedclock-example.html

      the main thing is they use a mask

       QRegion maskedRegion(width() / 2 - side / 2, height() / 2 - side / 2, side,
                               side, QRegion::Ellipse);
          setMask(maskedRegion);
      

      It cannot be done with QSS for top level windows.

      Outside such custom Windows, it's not really possible to alter how Windows looks like as it's the OS
      that controls that. Not Qt.
      That is why the window is still a rect in your picture.

      It often takes a huge amount of code to have a custom window if you at the same time wants it to be like any other window
      on that platform.

      See here how much code to have a frameless window on Windows and macOS
      https://github.com/Bringer-of-Light/Qt-Nice-Frameless-Window

      Linux is rarely supported as its flexibility to what actually draws the windows, makes it very hard to write that work across them all.

      1 Reply Last reply
      2
      • K Offline
        K Offline
        kokokaz
        wrote on last edited by
        #3

        Just add this :
        setAttribute(Qt::WA_TranslucentBackground);

        J 1 Reply Last reply
        2
        • K kokokaz

          Just add this :
          setAttribute(Qt::WA_TranslucentBackground);

          J Offline
          J Offline
          JustinGetty
          wrote on last edited by
          #4

          @kokokaz insane fix, thanks.

          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