Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a QTCreator-like left bar to my program?

I'm designing the GUI for a project, and I want a left bar like this ones

http://patatux.net/wp-content/uploads/2010/12/Pantallazo-BEBE-Me-fui.png
(source: patatux.net)

https://www.tuxradar.com/files/LXF119.rev_qt.04.jpg
(source: tuxradar.com)

How do I put them in my .ui file?

like image 384
JGDames Avatar asked Jun 06 '11 17:06

JGDames


1 Answers

You can try to use QToolBar with vertical orientation. To emulate tabs behavior you should put actions to QActionGroup and make them checkable.

For example to create left panel Qt creator like:

welcomeAct = new QAction(...)
toolbar->addAction(welcomeAct)
editAct = new QAction(...)
toolbar->addAction(editAct)
designAct = new QAction(...)
toolbar->addAction(designAct)
...

//add spacing
QLabel *spacing = new QLabel;
spacing->setSizePolicy(Qt::Expanding, Qt::Expanding);
toolbar->addWidget(spacing);

//adding aditional actions
runAct = new QAction(...)
toolbar->addAction(runAct)
runDebugAct = new QAction(...)
toolbar->addAction(runDebugAct)
buildAct = new QAction(...)
toolbar->addAction(buildAct)

// put "tabs" action in QActionGroup
group = new QActionGroup(this);
group->addAction(welcomeAct)
group->addAction(editAct)
group->addAction(designAct)
...
like image 163
Dmitriy Erlih Avatar answered Oct 03 '22 15:10

Dmitriy Erlih