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. Why qt draws sub widget on super bottom not on native nsview

Why qt draws sub widget on super bottom not on native nsview

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 121 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.
  • P Offline
    P Offline
    pengxu
    wrote on last edited by
    #1

    屏幕快照 2021-10-19 下午2.22.31.png

    int main(int argc, char *argv[])
    {    
        QApplication a(argc, argv);
        
        QWidget* mw = new QWidget();
        mw->setFixedSize(800, 600);
        NSView* leftView = reinterpret_cast<NSView*>(mw->winId());
        
        QWidget* canvas = new QWidget(mw);
        canvas->setGeometry(0, 0, 800, 600);
        canvas->setStyleSheet("background-color:red");
        
        QWidget* tool = new QWidget(mw);
        tool->setGeometry(0, 400, 800, 600);
        tool->setStyleSheet("background-color:green");
        
       
        QWidget* btn = new QWidget(tool);
        btn->winId();
        btn->setGeometry(0, 0, 100, 100);
        btn->setStyleSheet("background-color:white;");
        
        mw->show();
        return a.exec();
    }
    

    why all these red green and white color are drawn on the super bottom nsview? (Inspect it with xcode view hierarchy tool)
    If I set tool as native nsview and add layer, it's subview btn is drawn behinde the layer, why?

        NSView* tv = reinterpret_cast<NSView*>(tool->winId());
        [tv setWantsLayer:TRUE];
    
    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