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. Example from class QStyle's detailed description showing how to draw focus rect doesn't work
QtWS25 Last Chance

Example from class QStyle's detailed description showing how to draw focus rect doesn't work

Scheduled Pinned Locked Moved Unsolved General and Desktop
qstylefocus rectmacosqt 6.4
4 Posts 2 Posters 440 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
    Sky Lian
    wrote on last edited by Sky Lian
    #1

    macOS 13.2.1
    Qt 6.4.2

    MyWidget::MyWidget() :
        QWidget()
    {
        setFocusPolicy(Qt::StrongFocus);
        setAttribute(Qt::WA_MacShowFocusRect);
    }
    
    void MyWidget::paintEvent(QPaintEvent *event) {
            QStylePainter painter(this);
    
            QStyleOptionFocusRect option;
            option.initFrom(this);
            option.backgroundColor = Qt::darkCyan;
    
            painter.drawPrimitive(QStyle::PE_FrameFocusRect, option);
    }
    
    SGaistS 1 Reply Last reply
    0
    • S Sky Lian

      macOS 13.2.1
      Qt 6.4.2

      MyWidget::MyWidget() :
          QWidget()
      {
          setFocusPolicy(Qt::StrongFocus);
          setAttribute(Qt::WA_MacShowFocusRect);
      }
      
      void MyWidget::paintEvent(QPaintEvent *event) {
              QStylePainter painter(this);
      
              QStyleOptionFocusRect option;
              option.initFrom(this);
              option.backgroundColor = Qt::darkCyan;
      
              painter.drawPrimitive(QStyle::PE_FrameFocusRect, option);
      }
      
      SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Can you check whether you have the same issue with 6.5.0 that was just released ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        Can you check whether you have the same issue with 6.5.0 that was just released ?

        S Offline
        S Offline
        Sky Lian
        wrote on last edited by
        #3

        @SGaist
        I checked, and the problem remains, even if MyWidget inherits QLabel.

        SGaistS 1 Reply Last reply
        0
        • S Sky Lian

          @SGaist
          I checked, and the problem remains, even if MyWidget inherits QLabel.

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Looks like you may have unearthed a bug.

          You should check the bug report system to see if there's something already about it and if not please open a new ticket providing your findings.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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