I have a QHBoxLayout with a QLabel in it, and I'm trying to get both an icon and window title text in the QLabel. Is that possible? Or even to add the icon directly to the QHBoxLayout, so that is is laying just before the window title text?
Here is my code:
class MyBar(QWidget):
def __init__(self, parent):
super(MyBar, self).__init__()
self.parent = parent
self.layout = QHBoxLayout()
self.layout.setContentsMargins(0,0,0,0)
self.title = QLabel("Main Window")
def changetitle(self, msg):
self.title.setText(msg)
Edit:
Here is the code where I used two labels side by side:
self.label3 = QLabel(self)
self.title = QLabel("Main Window")
self.pixmap = QPixmap('res/myIcon.ico')
self.label3.setPixmap(self.pixmap)
self.label3.setAlignment(Qt.AlignCenter)
self.title.setFixedHeight(35)
self.title.setAlignment(Qt.AlignCenter)
self.layout.addWidget(self.label3)
self.layout.addWidget(self.title)
self.label3.setStyleSheet("""
background-color: black;
""")
self.title.setStyleSheet("""
background-color: black;
color: white;
""")