在下图中,红色矩形是菜单栏。我想创建绿色矩形所在的关闭按钮,但我不知道该怎么做。有什么建议?我想让UI看起来像Adobe Photoshop CS6?
答案 0 :(得分:1)
QMenuBar小部件有一个方法" setCornerWidget",你可以这样做:
// Hiden Window Title
setWindowFlags(Qt::FramelessWindowHint);
// Set widget on the top left corner
QPushButton* menuTopRightButton = new QPushButton("TL", m_menubar);
m_menubar->setCornerWidget(menuTopRightButton, Qt::TopLeftCorner);
// Set widget on the top right corner
QPushButton* menuTopLeftButton = new QPushButton("TR", m_menubar);
m_menubar->setCornerWidget(menuTopRightButton, Qt::TopRightCorner);
答案 1 :(得分:-1)
#closeButton {
position: absolute;
height:20px;
width:100px;
background:red;
float:right;
position:absolute;
right:0px;
top:0px;
}