M
M
Maxim0452020-02-10 16:57:23
Python
Maxim045, 2020-02-10 16:57:23

How to remove the border around the image placed in the button?

Using the PyQt5 module, I placed an image in the button. But a frame appeared around it, which I would like to remove (the picture will be below). I assume the solution is to set the size of the button to the size of the image using the setGeometry() method, but I didn't want to set the exact button coordinate value that this method requires. Please tell me how to remove the frame?

from PyQt5 import QtWidgets, QtGui, QtCore
import sys

app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QWidget()

button = QtWidgets.QPushButton('Button')

button = QtWidgets.QPushButton()
button.setIcon(QtGui.QIcon('picture1.png'))
button.setIconSize(QtCore.QSize(150, 150))
box1 = QtWidgets.QHBoxLayout()
box1.addWidget(button)
window.setLayout(box1)

window.show()
sys.exit(app.exec_())

5e41611207d49212061801.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ronald McDonald, 2020-02-10
@Maxim045

Try:

button {
border: none;
margin: 0px;
padding: 0px;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question