2 Attachment(s)
How to delete the shadow of buttons in QT?
Hi, all.
Currently, I am constructing a UI to control a mobile robot in ROS.
The following is the window of my ui:
Attachment 11510
Where both of the background of ui and buttons are set as transparent, and a png figure is set to every button.
Code:
MainWindow
::MainWindow(int argc,
char** argv,
QWidget *parent
) , qnode(argc,argv)
{
//Transparent
setWindowFlags(Qt::Widget | Qt::FramelessWindowHint);
setParent(0); // Create TopLevel-Widget
setAttribute(Qt::WA_NoSystemBackground, true);
setAttribute(Qt::WA_TranslucentBackground, true);
ui.setupUi(this); // Calling this incidentally connects all ui's triggers to on_...() callbacks in this class.
setWindowIcon
(QIcon(":/images/icon.png"));
QObject::connect(&qnode,
SIGNAL(rosShutdown
()),
this,
SLOT(close
()));
//buttons
ButtonBackground
(ui.
up_button,
QPixmap("/home/yrj/manny/src/jmr_qt/resources/images/up_up.png"));
ButtonBackground
(ui.
down_button,
QPixmap("/home/yrj/manny/src/jmr_qt/resources/images/down_up.png"));
ButtonBackground
(ui.
left_button,
QPixmap("/home/yrj/manny/src/jmr_qt/resources/images/left_up.png"));
ButtonBackground
(ui.
right_button,
QPixmap("/home/yrj/manny/src/jmr_qt/resources/images/right_up.png"));
ButtonBackground
(ui.
stop_button,
QPixmap("/home/yrj/manny/src/jmr_qt/resources/images/stop.png"));
ButtonBackground
(ui.
exit_button,
QPixmap("/home/yrj/manny/src/jmr_qt/resources/images/exit.png"));
{
//Bitmap
int width = button->size().width();
int height = button->size().height();
QIcon ButtonIcon
(pixmap
);
button->setFlat(true);
button->setStyleSheet("background-color: transparent;");
button->setIcon(ButtonIcon);
button
->setIconSize
(QSize(width, height
));
}
However, a shadow always exist, see the middle button of above figure.
And also the bottom button in the following figure:
Attachment 11511
Is there any method to hide or delete this shadow?
Thank you very much for your help.
Re: How to delete the shadow of buttons in QT?
1. Try button->setFocusPolicy(Qt::NoFocus) in MainWindow::ButtonBackground.
2. Write UI in QML.
Re: How to delete the shadow of buttons in QT?
It is working, thank you so much!!!:)
it is working, thank you so much!!!:)