Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, April 2008
Widgets in QToolbar issues


Message 1 in thread

Hi.

I want to add a QLineEdit in a QToolBar, using the method 
QToolBar::addWidget(). I think there's some problem in displaying the 
widgets. The QLineEdit is expanded to fill the entire empty space of the 
toolbar. If I set the maximum width of the QLineEdit, all the QAction in 
the toolbar are moved to fill the entire space of the toolbar. Instead, 
I expect that the QAction remains on the left and there is a empty space 
on the right.

The other problem is that if I try to hide the QLineEdit in the toolbar 
with the method QLineEdit::hide(), the QLineEdit remains visible.

Thanks.

Fabio.






      ___________________________________ 
Scopri il Blog di Yahoo! Mail: trucchi, novità, consigli... e la tua opinione!
http://www.ymailblogit.com/blog/

--
 [ signature omitted ] 

Message 2 in thread

On Tuesday 01 April 2008 18:03:54 Fabio Dago wrote:
> Hi.
>
> I want to add a QLineEdit in a QToolBar, using the method
> QToolBar::addWidget(). I think there's some problem in displaying the
> widgets. The QLineEdit is expanded to fill the entire empty space of the
> toolbar. If I set the maximum width of the QLineEdit, all the QAction in
> the toolbar are moved to fill the entire space of the toolbar. Instead,
> I expect that the QAction remains on the left and there is a empty space
> on the right.

the trick is to have a blank QWidget with a layout in the bar and then add 
your other widgets in the layout.

-- 
 [ signature omitted ] 

Message 3 in thread

Fabio wrote: 

> Hi.
> 
> I want to add a QLineEdit in a QToolBar, using the method 
> QToolBar::addWidget(). I think there's some problem in displaying the 
> widgets. The QLineEdit is expanded to fill the entire empty 
> space of the 
> toolbar. If I set the maximum width of the QLineEdit, all the 
> QAction in 
> the toolbar are moved to fill the entire space of the 
> toolbar. Instead, 
> I expect that the QAction remains on the left and there is a 
> empty space 
> on the right.
> 
> The other problem is that if I try to hide the QLineEdit in 
> the toolbar 
> with the method QLineEdit::hide(), the QLineEdit remains visible.
> 
> Thanks.

Hi Fabio, 

In 4.3.1, I had similar problems with QSlider stretching to fill the
toolbar. It was fixed by changing the sizePolicy on the slider. 

For the other problem, I think you need to save the action when you add the
widget, then use the action's mathods, not the lineedit's. For example: 

QAction lineEditAction = myToolBar->addWidget(..., myLineEdit);

...

lineEditAction->setVisible(false);

Note that Arvid's suggestion of only have one widget in the toolbar, and
everything else within it, might be simpler. 

Regards, 

Tony Rietwyk.

--
 [ signature omitted ]