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 to get a 1 pixel black border on a frameless dialog?
Qt 6.11 is out! See what's new in the release blog

How to get a 1 pixel black border on a frameless dialog?

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

    I have a couple of instances of a Dialog which I don't want a titlebar or widgets, so I call:

    setWindowFlags(Qt::FramelessWindowHint);
    

    In the class constructor, however I would like a single pixel, maybe 2 pixel black border around the dialog just to make it clear and standout when it overlays another dialog of the same background colour.

    I've tried setting the style sheet using:

    setStyleSheet("QDialog {border:1px solid black}");
    

    It doesn't do anything.

    Kind Regards,
    Sy

    Thank YouT 1 Reply Last reply
    0
    • HansonH Offline
      HansonH Offline
      Hanson
      wrote on last edited by
      #2

      You can try to override the paintEvent, maybe works.

      void YourWidget::paintEvent(QPaintEvent *)
      {
      QStyleOption opt;
      opt.init(this);
      QPainter p(this);
      style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
      }

      “Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.”
      —— Martin Golding

      1 Reply Last reply
      1
      • SPlattenS SPlatten

        I have a couple of instances of a Dialog which I don't want a titlebar or widgets, so I call:

        setWindowFlags(Qt::FramelessWindowHint);
        

        In the class constructor, however I would like a single pixel, maybe 2 pixel black border around the dialog just to make it clear and standout when it overlays another dialog of the same background colour.

        I've tried setting the style sheet using:

        setStyleSheet("QDialog {border:1px solid black}");
        

        It doesn't do anything.

        Thank YouT Offline
        Thank YouT Offline
        Thank You
        wrote on last edited by Thank You
        #3

        @SPlatten
        Set the stylesheet in the dialog

        using the editor
        ff728046-364f-4a00-9122-0ecca3e30a23-image.png
        Below is the code
        f66ebd75-d252-4dac-a630-25bcd71bac09-image.png
        If it didn't solve can you show more ? like how are you putting stylesheet?

        Let's make QT free or It will go forever

        TRUE AND FALSE <3

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved