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?

How is it possible to make rounded edges for QMainWindow?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 4 Posters 8.9k 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.
  • S Offline
    S Offline
    sepera_okeq
    wrote on 26 Jun 2021, 15:10 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
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 27 Jun 2021, 07:15 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 9 Aug 2024, 20:32 last edited by
        #3

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

        J 1 Reply Last reply 2 Nov 2024, 20:59
        2
        • K kokokaz
          9 Aug 2024, 20:32

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

          J Offline
          J Offline
          JustinGetty
          wrote on 2 Nov 2024, 20:59 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