我正在尝试使用QWidget :: create函数将QWidget放入X11窗口,但是我得到2个窗口而不是1个窗口:
class QTkMainWindow: public QWidget {
public:
QTkMainWindow(WId win)
:QWidget() {
QWidget::create(win, true, true);
}
};
void createApp(int argc, char **argv) {
Display *d;
Window w;
XEvent e;
int s;
d = XOpenDisplay(NULL);
s = DefaultScreen(d);
w = XCreateSimpleWindow(d, RootWindow(d, s), 10, 10, 100, 100, 1,
BlackPixel(d, s), WhitePixel(d, s));
XSelectInput(d, w, ExposureMask | KeyPressMask);
QApplication *qapp = new QApplication(argc, argv);
QTkMainWindow *win = new QTkMainWindow(w);
win->show();
XMapWindow(d, w);
while (1) {
XNextEvent(d, &e);
qapp->processEvents();
if (e.type == KeyPress)
break;
}
}
谁能告诉我我错过了什么?
谢谢!