

M_pMainWidget->setStyleSheet(" border: 1px solid lightgray background-color: #fafafa border-radius: 10px ") M_pCentralLayout->addWidget(m_pCentralWidget) M_pCentralLayout = new QHBoxLayout(m_pMainWidget) M_pCentralWidget->setStyleSheet("QWidget ") M_pCentralWidget = new QWidget(m_pMainWidget) M_pShadow = new QGraphicsDropShadowEffect(this) SetAttribute(Qt::WA_TranslucentBackground) SetWindowFlags((Qt::Dialog | Qt::FramelessWindowHint | this->windowFlags())) the pop-up window needs to set the following properties: The following are some important points in the source code.ġ. When the window pops up, click on the other location of the main window and the window disappears (there will be some minor defects due to the shadow effect, as described below).Ĥ. only one window can be displayed at the same time.ģ. The above renderings are implemented in way two. With one, we don't have to deal with all kinds of mouse events, but if we want to do it more beautiful, there will be many limitations, not easy to achieve. The other: click on a QPushButton and show a custom widget. One: using the QToolButton control, we can customize a widget, and then set Menu to the widget Has always thought that making a button popup window control is very simple, but it can be done to find that it is not so smooth, tossed for a long time, first look at the effect:
