NSView embed in QWidget covers other sibling widgets, why?
Unsolved
General and Desktop
-
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(); }
why the yellow remote nsview (which is in the red canvas) alwas covers the green tool widget (which is on top of red canvas)
mac os 10.13.6
-
Hi,
Which version of Qt are you using ?