PDA

View Full Version : toolbar initial position



baray98
5th September 2007, 23:44
I added a toolbar in a QMainWindow and wanted to have an initial position at Qt::BottomToolBarArea. I setAllowedAreas to that but this toolbar is always at the Qt::TopToolBarArea.

Is there any other way to set inital position of the tool bar?



QToolBar *toolBar = new QToolBar(this);
toolBar->setAllowedAreas( Qt::BottomToolBarArea);
setToolButtonStyle(Qt::ToolButtonTextUnderIcon);




baray98

wysota
6th September 2007, 01:14
Try this:


QToolBar *toolBar = new QToolBar(this);
mainWindow->addToolBar(Qt::BottomToolBarArea, toolBar);

baray98
6th September 2007, 16:41
it is still on the top area of the windows after adding


addToolBar(Qt::BottomToolBarArea,toolBar);


baray98

wysota
6th September 2007, 17:02
Which version of Qt are you using?

baray98
6th September 2007, 18:52
Qt 4.3.1 commercial version

marcel
6th September 2007, 19:03
That's impossible.
Have you added any actions to the toolbar?
Try:


toolbar->addAction("1");
toolbar->addAction("2");
toolbar->addAction("3");
toolbar->addAction("4");

after adding it to the main window.

With a default setup( you said you have qt commercial), the toolbar will be placed just above the status bar.

If the toolbar has no actions, it is hard to notice it. Also, an empty menu bar looks just like an empty toolbar, so you might have got the wrong impression.

Regards

baray98
6th September 2007, 22:07
i have added some widgets no actions on this toolbar so it's pretty noticeable . It still staying at the topToolBarArea....

baray98

wysota
7th September 2007, 07:39
Please try the following code:

#include <QApplication>
#include <QMainWindow>
#include <QToolBar>

int main(int argc, char **argv){
QApplication app(argc, argv);
QMainWindow mw;
QToolBar *tb = new QToolBar(&mw);
tb->addAction("a1");
tb->addAction("a2");
mw.addToolBar(Qt::BottomToolBarArea, tb);
mw.show();
return app.exec();
}