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

Qt-interest Archive, January 2007
Easy/quick way to create custom image pushbuttons?


Message 1 in thread

I want to create pushbuttons, and be able to have
several images for them:
1) Up, enabled
2) Down, enabled
3) Up, disabled
4) Down, disabled.
5) possibly other images such as 'focussed'
and 'being pressed' (halfway between up and down).

Confession: I haven't read every word in the docs about
QPushButtons etc.  I imagine I'll start with a QAbstractButton
derived class.  Has this kind of thing been done before?
Any sample code?  Or other approaches?

Thanks much.



--
 [ signature omitted ] 

Message 2 in thread

One easy way to do this, create a custom style, and using the style
options for the pushbutton, you can draw anything you want.

Including mouse over, disabled (there is no down disabled btw), enabled
up and enabled down.

Scott

> -----Original Message-----
> From: John Smith [mailto:invalid@xxxxxxxxxxx]
> Sent: Friday, January 05, 2007 4:55 PM
> To: qt-interest@xxxxxxxxxxxxx
> Subject: Easy/quick way to create custom image pushbuttons?
> 
> I want to create pushbuttons, and be able to have
> several images for them:
> 1) Up, enabled
> 2) Down, enabled
> 3) Up, disabled
> 4) Down, disabled.
> 5) possibly other images such as 'focussed'
> and 'being pressed' (halfway between up and down).
> 
> Confession: I haven't read every word in the docs about
> QPushButtons etc.  I imagine I'll start with a QAbstractButton
> derived class.  Has this kind of thing been done before?
> Any sample code?  Or other approaches?
> 
> Thanks much.
> 
> 
> 
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/

--
 [ signature omitted ] 

Message 3 in thread

Yes... however, the custom widget route can be painful in designer (not
impossible, but painful :-))

And has a major downside, only those pushbuttons create directly can
have it, meaning, dialogs that are owned by QT Widgets, wont.  Like a
color selector, or input dialog etc, will never paint the same way.



Of course, that may be preferred... 

 

I have been working on a very complex stylized environment, where we
actually had to do both.  First create our own custom image based push
button, and change the style for the push buttons we didn't want to
customize, but need to fit the over all style of the system.

 

If you want to check out what can be done with styles, check out
http://www.playlinc.com <http://www.playlinc.com/>  , the client was
completely developed in QT, and used some very advanced stylized systems

 

Scott

 

________________________________

From: jonas.gehring@xxxxxxxxxxxxxx [mailto:jonas.gehring@xxxxxxxxxxxxxx]
On Behalf Of Jonas Gehring
Sent: Friday, January 05, 2007 7:18 PM
To: Scott Aron Bloom
Subject: Re: Easy/quick way to create custom image pushbuttons?

 

You could also create a custom widget, add mouse tracking, overwrite
paintEvent to draw your image depending on the current state and finally
mouse*-routines to track the user input. You will need state variables
and maybe some slots (enable, disable), too. 

- Jonas



2007/1/6, Scott Aron Bloom <scott@xxxxxxxxxxxx>:

One easy way to do this, create a custom style, and using the style
options for the pushbutton, you can draw anything you want.

Including mouse over, disabled (there is no down disabled btw), enabled
up and enabled down. 

Scott

> -----Original Message-----
> From: John Smith [mailto:invalid@xxxxxxxxxxx]
> Sent: Friday, January 05, 2007 4:55 PM
> To: qt-interest@xxxxxxxxxxxxx
> Subject: Easy/quick way to create custom image pushbuttons?
>
> I want to create pushbuttons, and be able to have
> several images for them:
> 1) Up, enabled
> 2) Down, enabled
> 3) Up, disabled
> 4) Down, disabled.
> 5) possibly other images such as 'focussed'
> and 'being pressed' (halfway between up and down).
>
> Confession: I haven't read every word in the docs about 
> QPushButtons etc.  I imagine I'll start with a QAbstractButton
> derived class.  Has this kind of thing been done before?
> Any sample code?  Or other approaches?
>
> Thanks much.
> 
>
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body. 
> List archive and information: http://lists.trolltech.com/qt-interest/

--
 [ signature omitted ] 

Message 4 in thread

I also worked with styles, and they are indeed more comfortable. And once
you get the idea, a custom QStyle can be written quickly.
I thought that John wanted to create a single button, and in this case I
think it is easier to subclass a QWidget than to setup your own style.

- Jonas

// NOTE: I'm sorry, but my first mail had a wrong receiver. You can see my
first message in Scott's quotes

2007/1/6, Scott Aron Bloom <scott@xxxxxxxxxxxx>:
>
>  Yes… however, the custom widget route can be painful in designer (not
> impossible, but painful J)
>
> And has a major downside, only those pushbuttons create directly can have
> it, meaning, dialogs that are owned by QT Widgets, wont.  Like a color
> selector, or input dialog etc, will never paint the same way.
>
>  Of course, that may be preferred…
>
>
>
> I have been working on a very complex stylized environment, where we
> actually had to do both.  First create our own custom image based push
> button, and change the style for the push buttons we didn't want to
> customize, but need to fit the over all style of the system.
>
>
>
> If you want to check out what can be done with styles, check out
> http://www.playlinc.com , the client was completely developed in QT, and
> used some very advanced stylized systems
>
>
>
> Scott
>
>
>   ------------------------------
>
> *From:* jonas.gehring@xxxxxxxxxxxxxx [mailto:jonas.gehring@xxxxxxxxxxxxxx]
> *On Behalf Of *Jonas Gehring
> *Sent:* Friday, January 05, 2007 7:18 PM
> *To:* Scott Aron Bloom
> *Subject:* Re: Easy/quick way to create custom image pushbuttons?
>
>
>
> You could also create a custom widget, add mouse tracking, overwrite
> paintEvent to draw your image depending on the current state and finally
> mouse*-routines to track the user input. You will need state variables and
> maybe some slots (enable, disable), too.
>
> - Jonas
>
>  2007/1/6, Scott Aron Bloom <scott@xxxxxxxxxxxx>:
>
> One easy way to do this, create a custom style, and using the style
> options for the pushbutton, you can draw anything you want.
>
> Including mouse over, disabled (there is no down disabled btw), enabled
> up and enabled down.
>
> Scott
>
> > -----Original Message-----
> > From: John Smith [mailto:invalid@xxxxxxxxxxx]
> > Sent: Friday, January 05, 2007 4:55 PM
> > To: qt-interest@xxxxxxxxxxxxx
> > Subject: Easy/quick way to create custom image pushbuttons?
> >
> > I want to create pushbuttons, and be able to have
> > several images for them:
> > 1) Up, enabled
> > 2) Down, enabled
> > 3) Up, disabled
> > 4) Down, disabled.
> > 5) possibly other images such as 'focussed'
> > and 'being pressed' (halfway between up and down).
> >
> > Confession: I haven't read every word in the docs about
> > QPushButtons etc.  I imagine I'll start with a QAbstractButton
> > derived class.  Has this kind of thing been done before?
> > Any sample code?  Or other approaches?
> >
> > Thanks much.
> >
> >
> >
> > --
> > To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> > "unsubscribe" in the subject or the body.
> > List archive and information: http://lists.trolltech.com/qt-interest/
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
>

Message 5 in thread

Implementing a custom style (QStyle) sounds a little bit scaring.
Therefore, I just want to mention QStylePainter and/or QStyleSheet.
Perhaps, these will do the job in a derivative of QPushButton...

Regards, Clemens

Jonas Gehring wrote:
> I also worked with styles, and they are indeed more comfortable. And
> once you get the idea, a custom QStyle can be written quickly.
> I thought that John wanted to create a single button, and in this case
> I think it is easier to subclass a QWidget than to setup your own style.
>
> - Jonas
>
> // NOTE: I'm sorry, but my first mail had a wrong receiver. You can
> see my first message in Scott's quotes
>
> 2007/1/6, Scott Aron Bloom < scott@xxxxxxxxxxxx
> <mailto:scott@xxxxxxxxxxxx>>:
>
>     Yes… however, the custom widget route can be painful in designer
>     (not impossible, but painful J )
>
>     And has a major downside, only those pushbuttons create directly
>     can have it, meaning, dialogs that are owned by QT Widgets, wont. 
>     Like a color selector, or input dialog etc, will never paint the
>     same way.
>
>     Of course, that may be preferred…
>
>      
>
>     I have been working on a very complex stylized environment, where
>     we actually had to do both.  First create our own custom image
>     based push button, and change the style for the push buttons we
>     didn't want to customize, but need to fit the over all style of
>     the system.
>
>      
>
>     If you want to check out what can be done with styles, check out
>     http://www.playlinc.com <http://www.playlinc.com/> , the client
>     was completely developed in QT, and used some very advanced
>     stylized systems
>
>      
>
>     Scott
>
>      
>
>     ------------------------------------------------------------------------
>
>     *From:* jonas.gehring@xxxxxxxxxxxxxx
>     <mailto:jonas.gehring@xxxxxxxxxxxxxx>
>     [mailto:jonas.gehring@xxxxxxxxxxxxxx
>     <mailto:jonas.gehring@xxxxxxxxxxxxxx>] *On Behalf Of *Jonas Gehring
>     *Sent:* Friday, January 05, 2007 7:18 PM
>     *To:* Scott Aron Bloom
>     *Subject:* Re: Easy/quick way to create custom image pushbuttons?
>
>      
>
>     You could also create a custom widget, add mouse tracking,
>     overwrite paintEvent to draw your image depending on the current
>     state and finally mouse*-routines to track the user input. You
>     will need state variables and maybe some slots (enable, disable),
>     too.
>
>     - Jonas
>
>     2007/1/6, Scott Aron Bloom <scott@xxxxxxxxxxxx
>     <mailto:scott@xxxxxxxxxxxx>>:
>
>     One easy way to do this, create a custom style, and using the style
>     options for the pushbutton, you can draw anything you want.
>
>     Including mouse over, disabled (there is no down disabled btw),
>     enabled
>     up and enabled down.
>
>     Scott
>
>     > -----Original Message-----
>     > From: John Smith [mailto:invalid@xxxxxxxxxxx
>     <mailto:invalid@xxxxxxxxxxx>]
>     > Sent: Friday, January 05, 2007 4:55 PM
>     > To: qt-interest@xxxxxxxxxxxxx <mailto:qt-interest@xxxxxxxxxxxxx>
>     > Subject: Easy/quick way to create custom image pushbuttons?
>     >
>     > I want to create pushbuttons, and be able to have
>     > several images for them:
>     > 1) Up, enabled
>     > 2) Down, enabled
>     > 3) Up, disabled
>     > 4) Down, disabled.
>     > 5) possibly other images such as 'focussed'
>     > and 'being pressed' (halfway between up and down).
>     >
>     > Confession: I haven't read every word in the docs about
>     > QPushButtons etc.  I imagine I'll start with a QAbstractButton
>     > derived class.  Has this kind of thing been done before?
>     > Any sample code?  Or other approaches?
>     >
>     > Thanks much.
>     >
>     >
>     >
>     > --
>     > To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx
>     <mailto:qt-interest-request@xxxxxxxxxxxxx> with
>     > "unsubscribe" in the subject or the body.
>     > List archive and information: http://lists.trolltech.com/qt-interest/
>
>     --
>     To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx
>     <mailto:qt-interest-request@xxxxxxxxxxxxx> with "unsubscribe" in
>     the subject or the body.
>     List archive and information: http://lists.trolltech.com/qt-interest/
>
>      
>
>

--
 [ signature omitted ]