PDA

View Full Version : Floating toolbar window title



PUK_999
7th August 2009, 09:41
Hello,

Is there a way to show a toolbar's window title when it's floating?

I couldn't see anything in the QToolbar properties of the properties window, or any of the other properties for that matter.

Thanks,

PUK

yogeshgokul
7th August 2009, 10:39
You can set window title by passing the title in QToolBar constructor?

QToolBar::QToolBar ( const QString & title, QWidget * parent = 0 )
This should be visible when toolbar is floating.

PUK_999
7th August 2009, 11:06
Thanks for the reply. I think I need to give a little more info...

I'm using Designer and have a main window application that contains a mainToolBar (of type QToolBar). In the properties window, I set the windowTitle of this toolbar to something.

I'm not constructing the toolbar explicitly in my code. The generated ui_mainwindow.h does this, and in the retranslateUi() method it calls setWindowTitle with the text I specified in the properties window.

At runtime when the toolbar is dragged away from it's dock position to be made floatable, it floats but there is no title to it.

Is it possible to make this title show?

Thanks,

PUK

yogeshgokul
7th August 2009, 11:48
I dont think so, that there is any title thing in QToolBar.
You can work around like this:
Create a widget, set the window flag Qt::Tool. Add your items to this widget.
Add this widget to toolbar by addWidget.

PUK_999
8th August 2009, 15:18
I did try your suggestion. It didn't work. Title didn't show.

I'm not sure there's a trivial solution to the behaviour I want (toolbars to work as they do in utlook, Visual Studio, etc: when docked no title bar, when undocked there's a title bar).

For now I'm going to live with the toolbars as-is. It's not a big deal really. I just figured that the behaviour described above was fairly standard and it would just work as desired or have an option to make it do that.

I appreciate a Windows convention/standard is not necessarily a cross-platform convention and this may the reason its not doable (or doesn't appear to me to be) out of the box in Qt.

In the meantime, if anyone else knows of a quick way to do this, I'd like to hear it.

Thanks,

PUK