QWidget* Lin = new Lin();
QScrollArea* scrollArea = new QScrollArea();
scrollArea->setFrameStyle(0);
scrollArea->setWidget(Lin);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
QVBoxLayout * layout = new QVBoxLayout(this);
layout->setMargin(0);
layout->addWidget(scrollArea);
Lin->setFocus();
但是,当我点击鼠标或滚动父窗口小部件时,林会离开焦点;