Results 1 to 4 of 4

Thread: Formating problem in XReparentWindow

  1. #1
    Join Date
    Mar 2013
    Location
    Hyderabad,Bangalore,India
    Posts
    70
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Formating problem in XReparentWindow

    I am using the following program to embed a client window in another window using Qt and X11 code.

    I run the server program first and gets the window id of server using xwininfo(http://tronche.com/gui/x/xlib/window...entWindow.html).
    upon getting the window id , i run the client program by passing window id as a command line arguments.


    the problem is that the client window is embedding at the bottom , or at sides , or other but never from (0,0) geometry.

    and having the background of parent .

    how can i make the window to embed from 0,0 and should cover the size of its parent with auto size adjustable.


    client code

    Qt Code:
    1. using namespace std;
    2. #include <iostream>
    3. #include <QtWidgets>
    4. #include <X11/Xlib.h>
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication app(argc, argv);
    9. unsigned long int WinId;
    10. XSetWindowAttributes frame_attributes;
    11. WinId = atoi(argv[1]);
    12. cout<<"WinId :"<<WinId<<endl;
    13.  
    14. if(argc != 2){
    15. cout<<"pass WinId as arguement"<<endl;
    16. return 0;
    17. }
    18. Display *display = XOpenDisplay( 0 ); // 0 parameter for default values
    19. frame_attributes.background_pixel = XWhitePixel(display, 0);
    20. if ( display != NULL )
    21. {
    22. // Create the x11 window using XLib
    23. Window w = XCreateWindow(display, DefaultRootWindow(display),
    24. 0, 0, 200, 300, 0,CopyFromParent, CopyFromParent, CopyFromParent, CWBackPixel, &frame_attributes);
    25.  
    26. XMapWindow(display, w);
    27. XReparentWindow(display, w,WinId, 0, 0);
    28. XFlush(display);
    29. }
    30. else
    31. std::cout << "Error: Opening display" << std::endl ;
    32.  
    33. return app.exec();
    34. }
    To copy to clipboard, switch view to plain text mode 

    server code:

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent)
    2. : QMainWindow(parent)
    3. {
    4. QWidget *ServerWin = new QWidget;
    5. setCentralWidget(ServerWin);
    6. setMinimumSize(800,700);
    7. setPalette(QPalette(QColor(0,255,0,255)));
    8. setAutoFillBackground(true);
    9. }
    10.  
    11. MainWindow::~MainWindow()
    12. {
    13.  
    14. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Formating problem in XReparentWindow

    What if you pass the parent to XCreateWindow instead of reparenting?

    Cheers,
    _

  3. #3
    Join Date
    Mar 2013
    Location
    Hyderabad,Bangalore,India
    Posts
    70
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Formating problem in XReparentWindow

    Quote Originally Posted by anda_skoa View Post
    What if you pass the parent to XCreateWindow instead of reparenting?

    Cheers,
    _
    Thats Good,

    But i am not able to resize the client, does not the client resize when we maximize the parent?
    one more thing is , if i have some layouts on my server window and each layout is having different image then the cilent is having all those layouts as background instead of having its own parents.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Formating problem in XReparentWindow

    Quote Originally Posted by PstdEr View Post
    But i am not able to resize the client, does not the client resize when we maximize the parent?
    I guess that since it is not a widget but just widget content, you'll have to resize it manually.
    XResizeWindow in the resizeEvent() handler of the parent maybe.

    Quote Originally Posted by PstdEr View Post
    one more thing is , if i have some layouts on my server window and each layout is having different image then the cilent is having all those layouts as background instead of having its own parents.
    No idea, sorry.

    Cheers,
    _

Similar Threads

  1. Qt to Matlab (mat format) export data to Matlab .mat format -v4
    By windsword in forum Qt-based Software
    Replies: 4
    Last Post: 26th February 2013, 20:01
  2. Replies: 2
    Last Post: 3rd June 2011, 07:39
  3. Replies: 5
    Last Post: 1st June 2011, 08:28
  4. Replies: 1
    Last Post: 14th January 2011, 11:57
  5. Qt help in chm format
    By atb in forum Newbie
    Replies: 1
    Last Post: 24th January 2008, 05:07

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.