[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: How to keep QPushButtons small?
From:       Martijn Klingens <mklingens () yahoo ! com>
Date:       2001-12-29 22:23:12
[Download RAW message or body]

On Saturday 29 December 2001 22:15, Neil Stevens wrote:
> On Saturday December 29, 2001 12:51, Ellis Whitehead wrote:
> > I've spent the last couple hours trying to get widgets to not take up
> > more space than they need in the shortcut kcontrol module.  I've played
> > with QHBox, QHBoxLayout, QGridLayout, and more, but in all cases the
> > buttons are made much wider than they need to be, presumably in order to
> > create an 'optimal' visual spacing.  How to you get around this?  This
> > doesn't follow the behavior I'd expect from the Qt documentation...
>
> Change their size policy, I think.  See QWidget::setSizePolicy docs for
> details.

Yes, but QPushButtons are a bit special here as well. IIRC the buttons have a 
minimum width in many cases because many platforms on which Qt runs sort of 
require that. Although e.g. Qt on Windows doesn't use native Windows widgets 
Qt tries very hard to be conformant to the MS minimum strut size for buttons. 
At least for Qt 2 the QPushButton::sizeHint() function would never make 
buttons smaller than some 75 pixels or so. By subclassing QPushButton you can 
get around this. Maybe in Qt 3 the strut is less noticeable anyway, not sure 
about that. It looks to be configurable in qtconfig, though that might be 
another setting.

If the strut is not the problem, then Neil is right:

button->setSizePolicy( QSizePolicy( QSizePolicy::Minimum,
  QSizePolicy::Preferred ) );

should do your trick.

Martijn
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic