Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Embed Qt in an X11 window

Embed Qt in an X11 window

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vladbogo
    wrote on last edited by
    #1

    Hi,

    I am trying to embed Qt in an X11 window. My current approach uses the QWidget::create function:
    @
    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;
        }
    }
    

    @

    but unfortunately I get two windows instead of one.

    Can anyone give me some suggestion about what I might be missing or what different approach should I use?

    Thanks,
    Vlad

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Can I ask why? Qt on Linux uses X11 so it will create a X11 window for you automatically, no need to do it by hand... but you probably do have some specific use case.

      (Z(:^

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vladbogo
        wrote on last edited by
        #3

        I am currently trying to make a new Qt display manager for a program that actually uses Tk and the whole logic is for Tk, so embedding Qt will help me reduce a lot of effort.
        I was unsuccessful embedding Qt in Tk using the same approach, so I tried to embed in a raw X11 window to see if I miss something and also because I found more reference to Qt in X11 then Qt in Tk.

        So any suggestion on how to embed Qt in either X11 or Tk because it would really help me?

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved