0

我正在尝试使用 QWidget::create 函数将 QWidget 放在 X11 窗口中,但我得到了 2 个窗口而不是一个:

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;
    }
}

谁能告诉我我错过了什么?

谢谢!

4

0 回答 0