Results 1 to 6 of 6

Thread: QMainWindow to display X Window

  1. #1
    Join Date
    Jun 2009
    Location
    India
    Posts
    143
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QMainWindow to display X Window

    Hi all,

    I have developed a Qt application, with QMainWindow as main Object. Inside the same Qt application there is a X Window instructions to create a X Window. Code got compiled successfully . Both my Qt window and X window will display separately.Please refer the PNG attachment. I need the X Window to be displayed on QMainWindow. Somebody please guide.

    I got below errors when i am trying to integrate X and Qt

    X Error: BadWindow (invalid Window parameter) 3
    Major opcode: 3 (X_GetWindowAttributes)
    Resource id: 0x0
    Error: Couldn't find per display information

    I have attached the code of main.cpp for reference
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Join Date
    Jun 2009
    Location
    India
    Posts
    143
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QMainWindow to display X Window

    Some body who can help me ...

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QMainWindow to display X Window

    And how should we help you, without seeing any code of your application? Please provide a minimal compilable example, reproducing your problem.

  4. #4
    Join Date
    Jun 2009
    Location
    India
    Posts
    143
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QMainWindow to display X Window

    Quote Originally Posted by Lykurg View Post
    And how should we help you, without seeing any code of your application? Please provide a minimal compilable example, reproducing your problem.

    Hi Lkyurg,

    Hi, I have attached my code for your review in my thread. Have you seen that?

    For reference i have attached my code again. Any inputs required i am ready to provide

    Qt Code:
    1. #include <QApplication>
    2. #include <QX11EmbedWidget>
    3. #include <QWidget>
    4. #include <QX11Info>
    5. #include <QPaintDevice>
    6. #include <QGraphicsView>
    7. #include <QMainWindow>
    8.  
    9. /* Standard headers. */
    10. #include <stdio.h>
    11. #include <stdlib.h>
    12. #include <signal.h>
    13.  
    14. /* X headers. */
    15. #include <X11/StringDefs.h>
    16. #include <X11/Intrinsic.h>
    17. #include <X11/Core.h>
    18. #include <X11/Xaw/Box.h>
    19. #include <X11/Xaw/Command.h>
    20. #include <X11/Xaw/Form.h>
    21. #include <X11/Xaw/AsciiText.h>
    22. #include <X11/Xaw/Toggle.h>
    23. #include <X11/Shell.h>
    24.  
    25. /* SPx headers. */
    26. #include "SPx.h"
    27.  
    28. /*Class header */
    29. #include "Radar.h" // Class for creating QMainWindow
    30.  
    31. static int UpdateTimerMsecs = 50;
    32.  
    33. #define START_VIEW_X 0
    34. #define START_VIEW_Y 0
    35. #define START_VIEW_W 200000
    36. #define START_VIEW_H 200000
    37.  
    38. static void sigIntHandler(int sig)
    39. {
    40. printf("SIGINT received - exiting application.\n");
    41. exit(EXIT_SUCCESS);
    42. }
    43.  
    44. int main(int argc, char *argv[])
    45. {
    46. QApplication app(argc, argv);
    47.  
    48. Display *XDisplay = 0;
    49. int c;
    50. Radar *TopLevel= new Radar;
    51. Window win= TopLevel->winId();
    52.  
    53. qDebug("Window ID of win is %x",win);
    54.  
    55. //QGraphicsView *TopLevel;
    56. //QWidget *TopLevel= new QWidget;
    57. //QPaintDevice *TopLevel;
    58.  
    59. Display *display=TopLevel->x11Info().display();
    60. //Display *display=QX11Info::display();
    61. SPxScDestDisplayX11 *scDestX11;
    62. SPxScSourceLocal *ScanConverter = NULL;
    63.  
    64. double Vx = START_VIEW_X;
    65. double Vy = START_VIEW_Y;
    66. double Vw = START_VIEW_W;
    67. double Vh = START_VIEW_H;
    68. signal(SIGINT, sigIntHandler);
    69.  
    70. if( SPxInit() != SPX_NO_ERROR )
    71. {
    72. printf("Failed to initialise SPx.\n");
    73. exit(-1);
    74. }
    75.  
    76. XDisplay = display; //x11Info().
    77. qDebug("X Display %x",XDisplay);
    78.  
    79.  
    80. scDestX11 = new SPxScDestDisplayX11();
    81. scDestX11->UseDisplay(TopLevel->x11Info().display());
    82. scDestX11->Create(0, 1600, 1200, 0, 0, 0);
    83. scDestX11->SetUpdateInterval(UpdateTimerMsecs);
    84. SPxRIB *rib = new SPxRIB(1024 * 1024, NULL);
    85. SPxPIM *pim = new SPxPIM(rib, 2048, 2048, SPX_PIM_RAN_PEAK, SPX_PIM_AZI_PEAK, SPX_PIM_OUTPUT(1));
    86.  
    87. ScanConverter = new SPxScSourceLocal(scDestX11);
    88. ScanConverter->SetWinGeom(10,10,500,500);
    89. ScanConverter->ShowRadar(0,1);
    90. ScanConverter->SetFade(SPX_RADAR_FADE_REAL_TIME,200);
    91. new SPxRunProcess(SPxProScanConv, NULL, pim, ScanConverter);
    92.  
    93. SPxScFollowX11 *WinFollow = new SPxScFollowX11(ScanConverter,TopLevel->x11Info().display(),win,0); //Having doubts over this
    94.  
    95.  
    96. WinFollow->AddSC(ScanConverter);
    97.  
    98. WinFollow->CheckUnderTimer(250);
    99.  
    100. SPxTestGenerator *testGen = new SPxTestGenerator(rib, 2048, 2.0,1000,33, 0);
    101.  
    102. testGen->Enable(TRUE);
    103.  
    104.  
    105. TopLevel->show();
    106. return app.exec();
    107. }
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QMainWindow to display X Window

    True, I missed that there is a file attachment under the image. Sorry.

    In your code I can't figure out, where you set the X window in your TopLevel (QMainWindow) object (in a layout or similar). Also I can't see where you use QX11EmbedWidget.

  6. #6
    Join Date
    Jun 2009
    Location
    India
    Posts
    143
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QMainWindow to display X Window

    Quote Originally Posted by Lykurg View Post
    True, I missed that there is a file attachment under the image. Sorry.

    In your code I can't figure out, where you set the X window in your TopLevel (QMainWindow) object (in a layout or similar). Also I can't see where you use QX11EmbedWidget.
    Hi,

    Thanks for your reply .

    Completely new on integrating X with Qt. I didn't use QX11EmbedWidget? in my code . No idea of exactly how to use it in this case.

    In my code there are 3rd party libraries are used for X window creation.

    if You see the below code, it creates Window and use the display id ,given by me.

    Qt Code:
    1. SPxScDestDisplayX11 *scDestX11;
    2. scDestX11 = new SPxScDestDisplayX11();
    3. scDestX11->UseDisplay(TopLevel->x11Info().display()); // I am using QWindow as a display input ,Not sure whether its right
    4. scDestX11->Create(0, 1600, 1200, 0, 0, 0);
    To copy to clipboard, switch view to plain text mode 

    Below code is for giving the display details of Qt in it
    Qt Code:
    1. SPxScFollowX11 *WinFollow = new SPxScFollowX11(ScanConverter,TopLevel->x11Info().display(),win,0); // win is my Window id if you see the attached file
    To copy to clipboard, switch view to plain text mode 
    .

    If you want i can sent across the GTK code used by them for the same what i am trying to do with QT.

    Advise me.

Similar Threads

  1. QMainWindow as a child of QMainWindow
    By Elder Orb in forum Qt Programming
    Replies: 8
    Last Post: 12th February 2011, 21:31
  2. Open QMainWindow to use xterm window as parent
    By muenalan in forum Qt Programming
    Replies: 0
    Last Post: 1st July 2010, 08:43
  3. QMainWindow modal from non-qt window?
    By hickscorp in forum Qt Programming
    Replies: 3
    Last Post: 21st November 2008, 09:10
  4. Move QT Window to different x display
    By jbpvr in forum Qt Programming
    Replies: 1
    Last Post: 5th September 2007, 20:28
  5. how to display a window full screen??
    By Seema Rao in forum Qt Programming
    Replies: 1
    Last Post: 8th May 2006, 12: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.