This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Adjusting KDE windows of other applications from C++ code

Tags: None
(comma "," separated)
hunyadyi
Registered Member
Posts
2
Karma
0
Hi,
I want to move and resize some of my KDE windows on the Plasma desktop to given values from a "Qt Widgets Application" to get a stable desktop environment after startup. The KDE window rules did not work for me as expected, therefore I created a small widget application using Qt Creator to do the missing window adjustment task. I use the openSUSE Leap 15.4 distribution with C++ and Qt5 development packages installed, Plasma version is 5.24.4.

I succeeded to iterate on all KDE windows on the desktop and find the affected ones by comparing their titles by calling some KWindowSystem and KWindowInfo class methods, but I did not find any possibility to move and resize the affected windows, identified by the iterated window index of type WId. I know, that the move() and resize() methods of the QWidget class are to be used, but how can I address the QWidget of an other application by the iterated window index of type WId?

Here is the iteration code:

Code: Select all
    /* Read the KDE window list */
    QList<WId> list = KWindowSystem::windows();

    /* Find the windows to be adjusted */
    QList<WId>::iterator i;
    for (i = list.begin(); i != list.end(); i++)
    {
        KWindowInfo title_info = KWindowInfo(*i, NET::WMName);
        QString title = title_info.name();
        if (title.contains("MyWindow"))  // my affected window has been found
        {
            KWindowSystem::unminimizeWindow(*i);  // Make it visible, if it has been minimized (it works)
            // I want to adjust its position and size here...
        }
    }


Thanks for any help.

Should I post this question to an other forum?


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]