Embedding Qwidget into X11 window using X11 programming
-
Hi This is the program that i used from the net to embed a Qwidget into a x11 window.I am unable to see the Widget. Can anyone help me with it.
@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <QApplication>
#include "mywidget.h"#include <X11/Xlib.h>
QWidget* createWid(Display* d, Window w)
{
MyWidget* widget = new MyWidget(0);
if(widget)
{
widget->setWindowFlags(Qt::FramelessWindowHint);widget->setFocusPolicy(Qt::StrongFocus); widget->setWindowTitle( QApplication::translate("toplevel", "Top-level widget")); widget->move( 50, 50 );
widget->setFixedSize(100, 100);
widget->show();
widget->setFocus();
XReparentWindow(d, widget->winId(), w, widget->x(), widget->y());}
return widget;
}int main(int argc, char* argvp[])
{
Display *displayX;
Window window;
XEvent event;
char *msg = "Hello, World!";
int screen;QApplication qapp(argc, argvp);
displayX = XOpenDisplay(NULL);
if (displayX == NULL) {
fprintf(stderr, "Cannot open display\n");
exit(1);
}screen= DefaultScreen(displayX);
window = XCreateSimpleWindow(displayX, RootWindow(displayX, screen), 50, 50, 500, 500, 5, BlackPixel(displayX, screen), WhitePixel(displayX, screen));
XSelectInput(displayX, window, ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |KeyPressMask | KeyReleaseMask | ButtonPressMask
| ButtonReleaseMask
| KeymapStateMask | ButtonMotionMask | PointerMotionMask
| FocusChangeMask
| ExposureMask | StructureNotifyMask
| SubstructureNotifyMask | PropertyChangeMask);XMapWindow(displayX, window);
QWidget* wid ;
wid= createWid(displayX, window);while (1) {
XEvent event;
XNextEvent(displayX, &event);
if(wid != 0) {
fprintf(stderr, "QT widget");
qapp.x11ProcessEvent(&event);
}
}XCloseDisplay(displayX);
return 0;
}@
-
Hi was able to get the outer frame of the widget. solved by adding XMapRaised.
But button not visible. Please let me know about the additions in the code -
@sruthihsr: Please can you tell where do you insert XMapRaised ?