问题
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