Use Xlib inside Qt

♀尐吖头ヾ 提交于 2019-12-08 08:12:49

问题


I would like to be able to modify the Qt window's properties with Xlib fonctions.

I tried using QX11Info to get the display and QWidget::winId to get the window.

Display *display  = QX11Info::display();
int window = QWidget::winId ();

XMoveResizeWindow(display, window, 100, 100, 400, 400);

But it didn't work. I thought that maybe the window QWidget::winId () returns isn't the main one of the application. So I tried to modify its parent to see if it was the right window.

Display *display  = QX11Info::display();
int window = QWidget::winId ();

unsigned int nbChildren;
Window root,parent,*children;
XQueryTree(display, window, &root, &parent, &children, &nbChildren);

XMoveResizeWindow(display, parent, 100, 100, 400, 400);

But it didn't work either. I also tried XStoreName(display, window, "test Qt");for both example. The problem could have been that the window was not resisable.

I know I should do this kind of things with Qt directly but I am trying with easy fonctions to see if I can get the right window id. My goal is to change the window properties, using customs xlib intern atoms.

I would like to know what I am doing wrong.

Thank you.


回答1:


I found my error. The problem was that I was using these fonctions before the window was displayed.

Display *display  = QX11Info::display();
int window = QWidget::winId ();

XMoveResizeWindow(display, window, 100, 100, 400, 400);

This works if it is used after "show()".

Sorry for that.



来源:https://stackoverflow.com/questions/23359211/use-xlib-inside-qt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!