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. X11 Reparenting does not work.
Forum Updated to NodeBB v4.3 + New Features

X11 Reparenting does not work.

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.8k 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.
  • D Offline
    D Offline
    Dcqt
    wrote on last edited by
    #1

    I am trying to Reparent some widgets using x11 programming, but the windows are openings separately.

    what i expect is green color window inside red color window.

    what am i doing wrong.

    @

    using namespace std;
    #include <iostream>
    #include <QtWidgets>
    #include <X11/Xlib.h>

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    QWidget child ;
    child.setGeometry(33,33,555,555);
    child.setPalette(QPalette(QColor(0,255,0,255)));
    child.setAutoFillBackground(true);
    child.show();

       XSetWindowAttributes    frame_attributes;
      QWidget widget1 ;
       widget1.setGeometry(44,44,666,666);
       widget1.setPalette(QPalette(QColor(255,0,0,255)));
       widget1.setAutoFillBackground(true);
       widget1.show();
       Window w;
       Display *display = XOpenDisplay( 0 ); 
       int screen = DefaultScreen(display);
                 XSetWindowAttributes xswa;
                 xswa.background_pixel=BlackPixel(display, screen);
                 xswa.border_pixel=WhitePixel(display, screen);
                 xswa.event_mask=ExposureMask|KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|StructureNotifyMask;
          xswa.override_redirect = False;
    

    if ( display != NULL )
    {
    w = XCreateWindow(display, DefaultRootWindow(display),
    0, 0, 50, 50, 0,0,InputOutput, DefaultVisual(display, screen), CWEventMask|CWBackPixel|CWBorderPixel|CWOverrideRedirect, &xswa);

      XMapWindow(display, w);
      XReparentWindow(display, child->winId(),w, 0, 0);
      XReparentWindow(display,w, widget1.winId(), 0, 0);
    

    }else {
    std::cout << "Error: Opening display" << std::endl ;
    }
    return app.exec();
    }

    @

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi,

      See http://stackoverflow.com/questions/10089323/embedding-qwidget-into-x11-window It's a bit old, but might still work

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Rahul Das
        wrote on last edited by
        #3

        Line 36 : child is not a pointer.


        Declaration of (Platform) independence.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          Dcqt
          wrote on last edited by
          #4

          [quote author="JKSH" date="1384238774"]Hi,

          See http://stackoverflow.com/questions/10089323/embedding-qwidget-into-x11-window It's a bit old, but might still work[/quote]

          Thanks JKSH,

          I forgot that .

          I added

           @ XFlush(display);@
          

          after Reparenting, now windows are shown inside each other.

          but the problem is when i close the main window, the windows are getting closed, but the terminal does not show the promt.

          I am running application from terminal , do i need to destroy any windows on exit , if so where and which one to destroy.

          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