PDA

View Full Version : How do I create a toolbar like QT Creator's toolbar?



SteveHorwitz
9th September 2010, 15:59
Fellow QT users,

I am new to QT and I am in the process of creating my first QT application. As part of this application, I would like to create a toolbar similar to the toolbar that is located on the left hand side of QT Creator (it's the one that has buttons for "Edit", "Design", "Debug", etc.).

Would someone please tell me how this is done, or point me to where this is done in the source code for QT Creator?

Thank you very much.

Lykurg
9th September 2010, 16:09
Have a look here: http://qt.gitorious.org/qt-creator/qt-creator/trees/master.

SteveHorwitz
10th September 2010, 05:58
Lykurg,

Thank you for your reply.

What I see at http://qt.gitorious.org/qt-creator/q...r/trees/master appears to be
the entire source tree for Qt Creator. Could you be more specific as to where to
look for the Qt Creator toolbar? I have qt-creator-2.0.1-src. Which file(s) should
I look at?

Thank you.

Steve

tbscope
10th September 2010, 06:32
The base of a Qt Creator toolbar is in src/libs/utils/styledbar
To get the same graphics, you need to copy the toolbar painting code from the manhattan style too.

In src/plugins/coreplugin you have in implementation in the editortoolbar

Lykurg
10th September 2010, 07:14
If you don't like to go through the sources you can achieve a look a like very simple:

Subclass QDockWidget and reimp the paint event where you draw your desired background if you need a gradient. Otherwise simply set a custom palette to it.
Subclass a QPushButton where you also do your custom background painting for normal state and selected state. the rest is done by the default implementation.


Voila!

SteveHorwitz
11th September 2010, 15:29
Lykurg, tbscope,

Thank you for your replies. I'm on my way to creating my first StyledBar.

Steve