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?
Asked
Active
Viewed 2,045 times
1
-
MenuBar is simple widget. So... 1) Create a widget with MenuBar and your button inside. 2) Insert a button to the right side of MenuBar (+process related resize events) – Dmitry Sazonov Mar 03 '14 at 13:24
-
I'm very newbie. How can I create a widget with MenuBar and my button inside? and What is "+process related resize events" Thanks – delio Mar 03 '14 at 13:41
-
`QPushButton *btn = new QPushButton( pMenuBar );` – Dmitry Sazonov Mar 03 '14 at 14:10
-
Can you give me an example code. Please, I'm very in trouble. Thanks – delio Mar 03 '14 at 14:31
2 Answers
3
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);

LIANG LIU
- 81
- 4
-1
#closeButton {
position: absolute;
height:20px;
width:100px;
background:red;
float:right;
position:absolute;
right:0px;
top:0px;
}

douwe12345
- 65
- 1
- 1
- 7
-
-
1
-
-
@douwe12345 while this may answer the question it's usually better to give a brief description along with any code posted. It will help future visitors better understand why your answer is correct and may even give you a few upvotes :) – Mar 04 '14 at 08:36
-
@douwe12345: if this answer isn't relevant whatsoever I suggest you deleted it altogether. – Jeroen Vannevel Mar 04 '14 at 12:46