PDA

View Full Version : Newbie question about QToolBar



AlbertoN
24th May 2012, 11:26
Hello all,

I created a gui for my application like those of qtcreator where a QToolBar is placed on left side with several push button that switch app's central widget. Now i'd like to add another QToolBar placed just on right of the first one to create a submenu. I wrote this little snippet of code to show how QToolBar looks like:



class MainWindow: public QMainWindow
{
Q_OBJECT

public:
MainWindow(QWidget *parent=0);
void createActions();

private:
QToolBar *tb;
QToolBar *tab;
QAction *quitAction;
};

MainWindow::MainWindow(QWidget *parent)
{
createActions();

tb = new QToolBar();
tb->setFloatable(false);
tb->setMovable(false);
addToolBar(Qt::LeftToolBarArea,tb);
tb->setAllowedAreas(Qt::LeftToolBarArea);
tb->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
tb->setOrientation(Qt::Horizontal);
tb->addAction(quitAction);

tab = new QToolBar();
tab->setFloatable(false);
tab->setMovable(false);
tab->setAllowedAreas(Qt::LeftToolBarArea);
tab->setOrientation(Qt::Horizontal);
tab->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
addToolBar(Qt::LeftToolBarArea,tab);
tab->addAction(quitAction);
}


but QToolBar are below the other instead of one near the other. Is it possible to achive what i need, with QToolBar, and how?

I added a screenshot to show how i'd like the effect looks like.
7747

Thanks for any advice.
Al

mentalmushroom
28th May 2012, 06:38
Why are you using horizontal orientation?