4 October 2022
Abcdcheck this, should achieve what u want
https://pastebin.com/QQAEw8Yj
Ссылка
click to show
click to show
Still not working
https://0x0.st/oJpw.png
anya ♥Still not working
https://0x0.st/oJpw.png
Are you testing on a Linux system, what's your desktop environment?
I think maybe that your Desktop Environment compositor not compatible with translucent main widget.
You may need to test the same code on another DE, or probably better on Windows OS.
AbcdAre you testing on a Linux system, what's your desktop environment?
I think maybe that your Desktop Environment compositor not compatible with translucent main widget.
You may need to test the same code on another DE, or probably better on Windows OS.
Oh, could be. I'm using KDE and it's on X.org
anya ♥I expected KDE to support it so I never really checked but I guess not, I'm mostly only making this for myself, as a fun little project
Himmm,
Try to change the KWin compositor backend probably from OpenGL to XRender.
For now, I don't have running kde system so I can't test.
I'm trying to use @QmlSingleton to manage my global variables in python. According to the documentation I only need to use @QmlElement followed by @QmlSingleton so that QQmlEngine will try to create a singleton instance using the type’s default constructor. This is the code so far:
QML_IMPORT_NAME = "g1.backend.main"
QML_IMPORT_MAJOR_VERSION = 1
@QmlElement
@QmlSingleton
class MySingleton(QObject):
def __init__(self):
self.folderPath = scriptDir + os.path.sep + '\\temp\\'
@Slot(result=str)
def getArea(self):
return self.folderPath
Then I'm importing import g1.backend.main 1.0 from the qml file but I'm not able to call the MySigleton class. Do I need to register singleton or import differently?
This is the error:
<Unknown File>: qmlRegisterSingletonType(): "MySingleton" is not available because the callback function returns a null pointer.
Cristián 🥑can you drop the constructor of the class and place the content of the variable on the return statement?
Like this?
#To be used on the @QmlElement decorator
QML_IMPORT_NAME = "g1.backend.main"
QML_IMPORT_MAJOR_VERSION = 1
@QmlElement
@QmlSingleton
class MySingleton(QObject):
@Slot(result=str)
def getFolder(self):
folderPath = scriptDir + os.path.sep + '\\temp\\'
return folderPath
FranciscoLike this?
#To be used on the @QmlElement decorator
QML_IMPORT_NAME = "g1.backend.main"
QML_IMPORT_MAJOR_VERSION = 1
@QmlElement
@QmlSingleton
class MySingleton(QObject):
@Slot(result=str)
def getFolder(self):
folderPath = scriptDir + os.path.sep + '\\temp\\'
return f
yeah, but is scriptDir defined somewhere? otherwise it might be that the error is messing with the singleton
Cristián 🥑you are missing my first family name, but yes, that's me.
Nice to meet you sir! I love your youtube videos, by the way!
Cristián 🥑yeah, but is scriptDir defined somewhere? otherwise it might be that the error is messing with the singleton
No, I didn't define the scriptDir. I will check how to do this
FranciscoLike this?
#To be used on the @QmlElement decorator
QML_IMPORT_NAME = "g1.backend.main"
QML_IMPORT_MAJOR_VERSION = 1
@QmlElement
@QmlSingleton
class MySingleton(QObject):
@Slot(result=str)
def getFolder(self):
folderPath = scriptDir + os.path.sep + '\\temp\\'
return f
maybe you can try to return...say a hardcoded path to a folder that exists and see if you see the same behavior. We only have 1 example with QmlSingleton, and it's not doing something too difficult: https://doc-snapshots.qt.io/qtforpython-dev/examples/example_webenginequick__nanobrowser.html
FranciscoNice to meet you sir! I love your youtube videos, by the way!
oh you mean the ones on https://doc.qt.io/qtforpython/videos.html ? those are just conference talks, but I'm glad you enjoyed them.
FranciscoNo, I didn't define the scriptDir. I will check how to do this
maybe just write there return "c:\\" for example, or any other directory.
QML_IMPORT_NAME = "g1.backend.main"
QML_IMPORT_MAJOR_VERSION = 1
@QmlElement
@QmlSingleton
class MySingleton(QObject):
@Slot(result=str)
def getFolder(self):
return "c:\\"
and in QML I'm trying this:
Text {
id: lblFolderLocation
text: MySingleton.getFolder()
}
And the error is this now:
file:///C:/Users/Francisco/Documents/G1_QML/qml/pages/newAnalysis.qml:88:17: Unable to assign [undefined] to QString
Another option would be to create getters and access the class variable:
@QmlElement
class Getter(QObject):
@Slot(result=str)
def getFolder(self):
return Main.folderPath
Sorry for these questions. I come from data science and GUI, QML and OOP is quite new to me