PDA

View Full Version : QMainWindow to display X Window



augusbas
20th July 2010, 08:38
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

augusbas
20th July 2010, 14:37
Some body who can help me ...

Lykurg
20th July 2010, 14:54
And how should we help you, without seeing any code of your application? Please provide a minimal compilable example, reproducing your problem.

augusbas
21st July 2010, 05:50
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


#include <QApplication>
#include <QX11EmbedWidget>
#include <QWidget>
#include <QX11Info>
#include <QPaintDevice>
#include <QGraphicsView>
#include <QMainWindow>

/* Standard headers. */
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>

/* X headers. */
#include <X11/StringDefs.h>
#include <X11/Intrinsic.h>
#include <X11/Core.h>
#include <X11/Xaw/Box.h>
#include <X11/Xaw/Command.h>
#include <X11/Xaw/Form.h>
#include <X11/Xaw/AsciiText.h>
#include <X11/Xaw/Toggle.h>
#include <X11/Shell.h>

/* SPx headers. */
#include "SPx.h"

/*Class header */
#include "Radar.h" // Class for creating QMainWindow

static int UpdateTimerMsecs = 50;

#define START_VIEW_X 0
#define START_VIEW_Y 0
#define START_VIEW_W 200000
#define START_VIEW_H 200000

static void sigIntHandler(int sig)
{
printf("SIGINT received - exiting application.\n");
exit(EXIT_SUCCESS);
}

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

Display *XDisplay = 0;
int c;
Radar *TopLevel= new Radar;
Window win= TopLevel->winId();

qDebug("Window ID of win is %x",win);

//QGraphicsView *TopLevel;
//QWidget *TopLevel= new QWidget;
//QPaintDevice *TopLevel;

Display *display=TopLevel->x11Info().display();
//Display *display=QX11Info::display();
SPxScDestDisplayX11 *scDestX11;
SPxScSourceLocal *ScanConverter = NULL;

double Vx = START_VIEW_X;
double Vy = START_VIEW_Y;
double Vw = START_VIEW_W;
double Vh = START_VIEW_H;
signal(SIGINT, sigIntHandler);

if( SPxInit() != SPX_NO_ERROR )
{
printf("Failed to initialise SPx.\n");
exit(-1);
}

XDisplay = display; //x11Info().
qDebug("X Display %x",XDisplay);


scDestX11 = new SPxScDestDisplayX11();
scDestX11->UseDisplay(TopLevel->x11Info().display());
scDestX11->Create(0, 1600, 1200, 0, 0, 0);
scDestX11->SetUpdateInterval(UpdateTimerMsecs);
SPxRIB *rib = new SPxRIB(1024 * 1024, NULL);
SPxPIM *pim = new SPxPIM(rib, 2048, 2048, SPX_PIM_RAN_PEAK, SPX_PIM_AZI_PEAK, SPX_PIM_OUTPUT(1));

ScanConverter = new SPxScSourceLocal(scDestX11);
ScanConverter->SetWinGeom(10,10,500,500);
ScanConverter->ShowRadar(0,1);
ScanConverter->SetFade(SPX_RADAR_FADE_REAL_TIME,200);
new SPxRunProcess(SPxProScanConv, NULL, pim, ScanConverter);

SPxScFollowX11 *WinFollow = new SPxScFollowX11(ScanConverter,TopLevel->x11Info().display(),win,0); //Having doubts over this


WinFollow->AddSC(ScanConverter);

WinFollow->CheckUnderTimer(250);

SPxTestGenerator *testGen = new SPxTestGenerator(rib, 2048, 2.0,1000,33, 0);

testGen->Enable(TRUE);


TopLevel->show();
return app.exec();
}

Lykurg
21st July 2010, 08:57
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.

augusbas
21st July 2010, 15:00
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.


SPxScDestDisplayX11 *scDestX11;
scDestX11 = new SPxScDestDisplayX11();
scDestX11->UseDisplay(TopLevel->x11Info().display()); // I am using QWindow as a display input ,Not sure whether its right
scDestX11->Create(0, 1600, 1200, 0, 0, 0);

Below code is for giving the display details of Qt in it

SPxScFollowX11 *WinFollow = new SPxScFollowX11(ScanConverter,TopLevel->x11Info().display(),win,0); // win is my Window id if you see the attached file.

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.