I'm trying to delete this bar, butI can't get rid of it (it's locate just under the toolbar):
What is the name of that bar,how can I access it? Thank you.
What you are calling the toolbar
is actually the menu bar and what you are calling the other bar
is actually an emtpy toolbar.
The most likely reason you have an empty toolbar is because you created your window using QtDesigner. If you choose a QMainWindow
as your starting point, it automatically adds an empty menubar and an empty toolbar to the window. If you don't want the toolbar, find it in the Object Inspector on the right-hand side, right-click and select Remove Toolbar 'mainToolbar'
(or whatever other name is the default).
If you added that tool bar you probably have a pointer to it? If yes, you can simply call:
removeToolBar(toolbar);
in your QMainWindow
class. Otherwise you can remove all tool bars from the main window as:
QList<QToolBar *> allToolBars = mainWindow->findChildren<QToolBar *>();
foreach(QToolBar *tb, allToolBars) {
// This does not delete the tool bar.
mainWindow->removeToolBar(tb);
}
Below adds a little to @RobbieE's answer.
When creating a QMainWindow
form, it creates mainToolBar
for the user.
If you right click on it and select Remove Toolbar 'mainToolBar'
it will be gone.
Or in code in the top of your constructor:
ui->setupUi(this);
delete ui->mainToolBar; // add this line
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With