Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-99514

NSView embeded in QWidget covers the sibling qwidgets on mac os 10.13

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 5.15.0 RC2
    • Fix Version/s: None
    • Labels:
      None
    • Platform/s:
      macOS

      Description

      The code are below:
       

      int main(int argc, char *argv[])
      { 
        QApplication a(argc, argv); 
        QWidget* mw = new QWidget(); 
        mw->setFixedSize(800, 600); 
        QWidget* canvas = new QWidget(mw); 
        canvas->setGeometry(0, 0, 800, 600); 
        canvas->setStyleSheet("background-color:red"); 
        NSView* remote = [[NSView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)]; 
        [remote setWantsLayer:true]; remote.layer.backgroundColor = [NSColor yellowColor].CGColor; 
        NSView* cv = reinterpret_cast<NSView*>(canvas->winId()); 
        [cv addSubview:remote]; 
        [remote setTranslatesAutoresizingMaskIntoConstraints:NO];       
        [remote.bottomAnchor constraintEqualToAnchor:cv.bottomAnchor constant:0.0f].active = YES; 
        [remote.leadingAnchor constraintEqualToAnchor:cv.leadingAnchor constant:50.0f].active = YES; 
        [remote.widthAnchor constraintEqualToAnchor:cv.widthAnchor multiplier:1.0f constant:0.0f].active = YES; 
        [remote.heightAnchor constraintEqualToAnchor:cv.heightAnchor multiplier:1.0f constant:0.0f].active = YES; 
        QWidget* tool = new QWidget(mw); 
        tool->setGeometry(0, 400, 800, 600); 
        tool->setStyleSheet("background-color:green"); mw->show(); 
        return a.exec(); 
      }
      

       

      on mac os 10.13 the yellow nsview covers the green tool widget, when mac os version is greater than 10.13, it works fine

        Attachments

        1. screenshot-1.png
          screenshot-1.png
          323 kB
        2. T7wRN.png
          T7wRN.png
          16 kB
        3. 屏幕快照 2022-01-07 下午6.57.09.png
          屏幕快照 2022-01-07 下午6.57.09.png
          35 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            vestbo Tor Arne Vestbø
            Reporter:
            xp19870106 peng xu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes