delio
delio

Reputation: 91

How can I create close button on Menu bar?

In the picture below, the red rectangle is the menu bar. I want to create close button where the green rectangle is, but I don't know how can I do that. Any suggestions? I'd like to make the UI look like Adobe Photoshop CS6?

screenshot

Upvotes: 1

Views: 2205

Answers (2)

LIANG LIU
LIANG LIU

Reputation: 91

The QMenuBar widget has a method "setCornerWidget", You can do what you want like this:

    // 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);

Upvotes: 3

douwe12345
douwe12345

Reputation: 65

#closeButton {
position: absolute;
height:20px;
width:100px;
background:red;
float:right;
position:absolute;
right:0px;
top:0px;
}

http://jsfiddle.net/6U5p8/

Upvotes: -1

Related Questions