Results 1 to 5 of 5

Thread: How to determine desktop number?!?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2015
    Location
    Poland
    Posts
    34
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Angry How to determine desktop number?!?

    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:
    Qt Code:
    1. MainWindow w;
    2. reinterpret_cast<quint64>(w.windowHandle()->screen()
    To copy to clipboard, switch view to plain text mode 
    Which is wrong because it is unique from instance to instance.
    2. Find siblings of current screen:
    Qt Code:
    1. QList<QScreen*> lScreens(w.windowHandle()->screen()->virtualSiblings());
    2. for(QScreen* lScreen : lScreens)
    3. qInfo() << "Detected screen: " << reinterpret_cast<quint64>(lScreen);
    To copy to clipboard, switch view to plain text mode 
    But it return only first screen (3 rest are ignored).
    3. Identify by primaryScreen pointer:
    Qt Code:
    1. qInfo() << "Detected screen: " << reinterpret_cast<quint64>(a.primaryScreen());
    To copy to clipboard, switch view to plain text mode 
    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?

  2. #2
    Join Date
    Jul 2012
    Posts
    244
    Thanks
    27
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to determine desktop number?!?

    Did you pass your text editors widget to QDesktopWidget::screenNumber(QWidget*) ? Show some code.

Similar Threads

  1. Determine Linux desktop version
    By RolandHughes in forum Qt Programming
    Replies: 3
    Last Post: 23rd June 2015, 19:05
  2. Replies: 1
    Last Post: 5th March 2012, 06:34
  3. Determine the Process ID
    By Jimmy2775 in forum General Programming
    Replies: 5
    Last Post: 7th October 2011, 09:16
  4. How to determine type of cd?
    By AlexanderPopov in forum Qt Programming
    Replies: 1
    Last Post: 26th May 2010, 09:20
  5. Replies: 5
    Last Post: 31st January 2009, 07:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.