PDA

View Full Version : Designer: How to promote to a existing Qt Widget?



nightghost
8th December 2009, 10:43
Good Morning,

I want to insert a QToolBar into my QWidget designed in the Designer. Since there is no direct support for this (except for QMainWindow, but I cant use this) I thought its best to use a normal QWidget and promote it to the QToolBar. But this seems not possible in the designer (4.6.0).

However a can create a Custom Widget based on QToolBar, but I can not select it for promoting, since my Baseclass is QWidget and not QToolBar. For selecting this I need a QToolbar as Base (and this is exacly what I want)

http://www.qtcentre.org/forum/attachment.php?attachmentid=3963&stc=1&d=1260265306

yogeshgokul
8th December 2009, 10:59
First of all you misconcepted the meaning of promotion. Promotion is used for promoting the default widgt to a customized widget in designer. e.g. You have subclassed QLabel and created a class MyLabel. Then while using MyLabel in designer you need to place a QLabel and promote it to MyLabel. There is no meaning of promoting it to QLabel because its a QLabel already.

Secondly, whats the problem in subclassing QMenubar ? Have you tried that or what ?

nightghost
9th December 2009, 10:12
After reading my post again I see, that it is a bit difficult to understand. So here is a longer explanation:

I know the purpose of promoting, but I thought I could (ab)use it to achieve my goal inserting a QToolBar into my widget into the designer.

Like: This a QWidget promoted to QToolBar. Adding the right header and setting it to global. In this way the uic would included the code for the QToolBar (that was my idea, but it didn't work, because the designer knows, that QToolBar is a special widget of Qt and don't allow this)

While playing with this I detected, that it is possible to subclass from QToolBar in the promoting dialog. So I thought that is must be possible to insert a QToolBar directly, since its not possible to promote a normal QWidget to a class, that inherit from QToolBar. That was my state when I was writing the post: "There is a way to directly insert a QToolBar, else this feature would make no sense"

But after a bit research the only way to insert a QToolBar seem to use QMainWindow and then "add toolbar". (and this one you could use to promote to a custom widget that is inheriting QToolBar)

How could QMenuBar help me in my case? It seems to have the same limitations as the QToolBar