Szyk
17th November 2018, 15:43
Hi!
I am writing text editor in multiplatform way. In the past I most time spending on Windows, but now I am back to the Linux and I want next version of my text editor will be usable on Linux also.
Now am working with Kubuntu 18.10 with Kde Plasma windows manager. I have 4 virtual desktops. Most of the time I am working only with first of them. But I can image to work with file manager on some other screen and I want to run my editor from file manager many times (intense working with source files in many languages). I do some basic tests and I am failed to find "right Qt way" to determine number of desktop on which my text editor is running. I try:
1. Identify by screen pointer:
MainWindow w;
reinterpret_cast<quint64>(w.windowHandle()->screen()
Which is wrong because it is unique from instance to instance.
2. Find siblings of current screen:
QList<QScreen*> lScreens(w.windowHandle()->screen()->virtualSiblings());
for(QScreen* lScreen : lScreens)
qInfo() << "Detected screen: " << reinterpret_cast<quint64>(lScreen);
But it return only first screen (3 rest are ignored).
3. Identify by primaryScreen pointer:
qInfo() << "Detected screen: " << reinterpret_cast<quint64>(a.primaryScreen());
But it failed also (it is unique from instance to instance).
4. QDesktopWidget::screenNumber()
But it always return 0 (no mater what is current desktop).
Do you have any other ideas?
I am writing text editor in multiplatform way. In the past I most time spending on Windows, but now I am back to the Linux and I want next version of my text editor will be usable on Linux also.
Now am working with Kubuntu 18.10 with Kde Plasma windows manager. I have 4 virtual desktops. Most of the time I am working only with first of them. But I can image to work with file manager on some other screen and I want to run my editor from file manager many times (intense working with source files in many languages). I do some basic tests and I am failed to find "right Qt way" to determine number of desktop on which my text editor is running. I try:
1. Identify by screen pointer:
MainWindow w;
reinterpret_cast<quint64>(w.windowHandle()->screen()
Which is wrong because it is unique from instance to instance.
2. Find siblings of current screen:
QList<QScreen*> lScreens(w.windowHandle()->screen()->virtualSiblings());
for(QScreen* lScreen : lScreens)
qInfo() << "Detected screen: " << reinterpret_cast<quint64>(lScreen);
But it return only first screen (3 rest are ignored).
3. Identify by primaryScreen pointer:
qInfo() << "Detected screen: " << reinterpret_cast<quint64>(a.primaryScreen());
But it failed also (it is unique from instance to instance).
4. QDesktopWidget::screenNumber()
But it always return 0 (no mater what is current desktop).
Do you have any other ideas?