PDA

View Full Version : How to remove 3D frame and outline in QToolButton?



Kevin Hoang
9th March 2010, 04:55
I have a problem with QToolButton in removing default 3D frame and outline. I don't know how to remove 3D frame and outline in QToolButton when the mouse points at it?

Somebody help me!

aamer4yu
9th March 2010, 05:05
How will user then know that hes about to click the button ?
What functionality you want to achieve ?

May be meanwhile you can have look at autoRaise property of QToolButton. Also if you are using QPushButton, you can use setFlat(true).

Kevin Hoang
9th March 2010, 05:16
Thank you very much!

I'm using an image instead default QT button, when users points the mouse as it, it will display another image.

I didn't see setFlat function in QToolButton. Can you help me where this function is available.

wagmare
9th March 2010, 05:24
Thank you very much!

I'm using an image instead default QT button, when users points the mouse as it, it will display another image.

I didn't see setFlat function in QToolButton. Can you help me where this function is available.

means u are using a QToolButton or a pixmap which u want the image to act it like a button ..?

Kevin Hoang
9th March 2010, 05:50
means u are using a QToolButton or a pixmap which u want the image to act it like a button ..?

exactly, below that image is text.

wagmare
9th March 2010, 06:21
ok create a own widget with a pixmap added in label1 and below label2 the text u want to display ... override the void QWidget::mousePressEvent ( QMouseEvent * event ) and emit your custom signal


void
customButton::mousePressEvent(QMouseEvent *event)
{
if (event->button() != Qt::LeftButton)
{
QWidget::mousePressEvent(event);
return;
}
emit
myOwnSignal();
}
this signal will be emitted when user press or click on the widget ..:o

Kevin Hoang
9th March 2010, 10:00
wagmare: Thank you very much!

Does it have any other ways?

wagmare
9th March 2010, 10:08
Does it have any other ways?

then u can use autoRaise property set to true in QToolButton what aamer suggest .... its the only option ..
use setIcon(const QIcon icon) of QToolButton to set the image and set toolButtonStyle() to Qt::ToolButtonTextUnderIcon

Kevin Hoang
9th March 2010, 10:26
then u can use autoRaise property set to true in QToolButton what aamer suggest .... its the only option ..
use setIcon(const QIcon icon) of QToolButton to set the image and set toolButtonStyle() to Qt::ToolButtonTextUnderIcon

By this way, it doesn't remove default style (3D Frame and outline) when users points mouse as it. :)

wysota
9th March 2010, 14:31
I'm using an image instead default QT button, when users points the mouse as it, it will display another image.

Are you doing that though style-sheets? If so, what exactly is your style-sheet? If not then why not?