30 December 2022
Anton Yablokovtext not yet in the index
from PyQt6 import QtWidgets, QtCore
import sys
class loaderUi(QtWidgets.QMainWindow):
def __init__(self, MainWindow):
super().__init__()
self.MainWindow = MainWindow
MainWindow.showMaximized()
def setupUi(self):
MainWindow = self.MainWindow
self.centralWidget = QtWidgets.QWidget(MainWindow)
self.layout = QtWidgets.QGridLayout(self.centralWidget)
self.label = QtWidgets.QLabel('test')
self.label.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
font = self.label.font()
font.setPointSize(160)
font.setBold(True)
self.label.setFont(font)
self.label2 = QtWidgets.QLabel('test2', self.label)
self.label2.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
font = self.label2.font()
font.setPointSize(160)
font.setBold(True)
self.label2.setFont(font)
self.layout.addWidget(self.label)
MainWindow.setCentralWidget(self.centralWidget)
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = loaderUi(MainWindow)
ui.setupUi()
MainWindow.show()
app.exec()
It's .frameGeometry(): PyQt6.QtCore.QRect(0, 0, 640, 480)
id 2092537693text not yet in the index
Another way I can think of is using mapToGlobal for the window and for the widget, and then subtract one point from another. Maybe, mapTo works simpler, but the description is not that clear.
hey @mcdamn7 thanks for your reply, please consider using external services like pastie.org to share code.
This channel is bridged to IRC as well, and your message now is a wall of text, because it represent one-line as a separate message.
Additionally, keep in mind this is a PySide channel, not a PyQt one.
Anton YablokovAnother way I can think of is using mapToGlobal for the window and for the widget, and then subtract one point from another. Maybe, mapTo works simpler, but the description is not that clear.
it's full-screen window
>>> print(self.pos())
>>> print(self.label.pos())
PyQt6.QtCore.QPoint()
PyQt6.QtCore.QPoint()
id 2092537693it's full-screen window
>>> print(self.pos())
>>> print(self.label.pos())
PyQt6.QtCore.QPoint()
PyQt6.QtCore.QPoint()
After you show the window, the left-top corner of the label is at ui.label.mapTo(ui, QtCore.QPointF(0, 0)). However, the very placement of the labels makes me look into ui.layout.contentsMargins(). One way or another, I get (9, 9). For you, the layout might differ, though.
Beware that it takes a while before the OS places the window wherever it considers the best, so don't get the coordinates until the window is painted (or just wait a second).
Anton YablokovAfter you show the window, the left-top corner of the label is at ui.label.mapTo(ui, QtCore.QPointF(0, 0)). However, the very placement of the labels makes me look into ui.layout.contentsMargins(). One way or another, I get (9, 9). For you, the layout might differ, though.
Beware that it takes a wh
(9, 9) so low. coz i tried manually move label2 and it's near ~500 by x and y
id 2092537693(9, 9) so low. coz i tried manually move label2 and it's near ~500 by x and y
The label spans over all the space given. Enable its frame to see.
Anton YablokovThe label spans over all the space given. Enable its frame to see.
maybe you mean layout? coz label in layout 😅
id 2092537693maybe you mean layout? coz label in layout 😅
Negative. The label. Make its frame visible. It spans with 9 point (or pixel?) gap from the window border. That's how QGridLayout behaves.
id 2092537693how can i place label in back of parent(QLabel) ?
please try to reword your question, I don't understand what do you want
tomaz canabravaplease try to reword your question, I don't understand what do you want
I have 2 labels:
1. QLabel(it’s my obj, QLabel inherited)
2. QLabel.shadowText(parent - 1.)
How can i place 2. In back of 1. (to seem like 2. Is shadow of 1.)
id 2092537693I have 2 labels:
1. QLabel(it’s my obj, QLabel inherited)
2. QLabel.shadowText(parent - 1.)
How can i place 2. In back of 1. (to seem like 2. Is shadow of 1.)
Why don't you try styling the label with CSS (yeah, quite like what is in HTML). It won't help you with the positioning, but it can make a shadow.
@mcdamn7 u can use dropshadoweffect https://doc.qt.io/qtforpython-5/PySide2/QtWidgets/QGraphicsDropShadowEffect.html
Ссылка
click to show
click to show
example if you use qtwidgets > https://www.geeksforgeeks.org/pyqt5-label-adding-shadow/
id 197506226@mcdamn7 u can use dropshadoweffect https://doc.qt.io/qtforpython-5/PySide2/QtWidgets/QGraphicsDropShadowEffect.html
I wanna use opacityEffect, but it’s hard to do new Custom Effect
id 2092537693as i got, not all css styles are working
No, there is a subset of CSS properties. To my mind, they are more than enough for simple styling. Once you exceed the capabilities, the widgets get heavy to paint and, consequently, interact with.
Anton YablokovNo, there is a subset of CSS properties. To my mind, they are more than enough for simple styling. Once you exceed the capabilities, the widgets get heavy to paint and, consequently, interact with.
what i need paste to make shadow for my text👉👈
text-shadow not working, box-shadow too
id 2092537693from PyQt6 import QtWidgets, QtCore
import sys
class loaderUi(QtWidgets.QMainWindow):
def __init__(self, MainWindow):
super().__init__()
self.MainWindow = MainWindow
MainWindow.showMaximized()
def setupUi(self):
MainWindow = self.MainWindow
self.cent
Please when posting code snippets, if they are longer than like, 10 or 15 lines, use a pastebin service.