tags:

views:

332

answers:

1

I have a QToolbar with toolButtonStyle set to Qt::ToolButtonTextUnderIcon in which I add a QLineEdit through addWidget(). I'd like to have descriptive text under that widget like I do with other buttons, but I don't know how to do it or if it's even possible. I tried:

lineEdit = QLineEdit()
action = self.toolBar.addWidget(lineEdit)
action.setText("Some Text")

But it doesn't work. Is it possible at all? If not, are there special techniques I don't know about to put text under that widget in a way that it's aligned with the other labels regardless of the style?

+1  A: 

toolButtonStyle refers to buttons' label position only, while you're adding a QLineEdit. To put a label under your line edit try arranging a layout, a QVBoxLayout for example

Masci
Yeah, I guessed I would end up having to do this, but what I fear is all this fuss-around I'll have to do to adjust my layout's margin depending on the current platform/style and I was wondering if anyone had done this before.
Virgil Dupras
You could write a custom MyToolbarWidget deriving from QWidget encapsulating layout policy and setup. Your custom widget could also behave according to the value of toolButtonStyle property exposed by the QToolbar
Masci