[Qt-interest] QPushButton - remain down...

BRM bm_witness at yahoo.com
Tue Mar 2 18:28:34 CET 2010


----- Original Message ----

> On Mar 2, 2010, at 9:32 AM, BRM wrote:
> > I have a series of items I am putting into a QToolBar so the user can select 
> them during run.
> > Presently I am using the QCheckBox, but it takes up a lot of room.
> > Preferably, I'd like to have a QPushButton kind of widget that has two states: 
> Up and Down.
> > Looking through the documentation, I did notice that QPushButton has those 
> states, but it does not seem to remain in those states.
> > Am I missing something to enable this?
> > Or am I going to need to subclass?
> I'm pretty sure you can make it checkable (setCheckable(true)) to do what you 
> want. Not necessarily intuitive...

Thanks - that did it.
 
----- Original Message ----
> From: Robert Hairgrove 
<evorgriahr at hispeed.ch>
> BRM wrote:
> > I have a series of items I am putting into a QToolBar so the user can 
select 
> them during run.
> > Presently I am using the 
QCheckBox, but it takes up a lot of room.
> > Preferably, I'd 
like to have a QPushButton kind of widget that has two states: 
> 
Up and Down.
> > Looking through the documentation, I did 
notice that QPushButton has those 
> states, but it does not seem 
to remain in those states.
> > Am I missing 
something to enable this?
> > Or am I going to need to 
subclass?
> > Note: I'm presently using Qt 4.5 
(4.5.1, 4.5.2).
> Did you look at the QToolButton 
class yet?

Yes I did.

When I was originally reading through all of it there were several things that popped out to me:

- QPushButton documentation mentions:"If you need toggle behavior (see setCheckable()) or a button that auto-repeats the activation signal when being pushed down like the arrows in a scroll bar (see setAutoRepeat()), a command button is probably not what you want. When in doubt, use a tool button."
- QPushButton does not generate the setChecked() signal, only QCheckBox does.
- QToolButton seemed not to do what I wanted; though the above probably applies to it as well.

So as Brad said - it's not intuitive on how to do this.

Thanks all!

Ben




More information about the Qt-interest-old mailing list