PDA

View Full Version : Creating Qgraphics View code



amagdy.ibrahim
14th June 2008, 16:55
I need to create gpraphics view with code,I wrote in the header file
QGraphicsView *view;
then in cpp file
I wrote creating the form

view = new QGraphicsView(&(MdiChild::newFile));

void MdiChild::newFile()
{
static int sequenceNumber = 1;

isUntitled = true;
curFile = tr("document%1.txt").arg(sequenceNumber++);
setWindowTitle(curFile + " ");

// connect(document(), SIGNAL(contentsChanged()),
// this, SLOT(documentWasModified()));
}

I have an error
would you please help me?

wysota
14th June 2008, 17:35
view = new QGraphicsView(&(MdiChild::newFile));
This code seems invalid. What is MdiChild::newFile? What is the error you get?

amagdy.ibrahim
14th June 2008, 17:55
mainwindow.h:73:error expected ';' before '*'

I need to create qgraphics in mdichild when I press on new button in the mainwindow

void MdiChild::newFile()
{
static int sequenceNumber = 1;

isUntitled = true;
curFile = tr("document%1.txt").arg(sequenceNumber++);
setWindowTitle(curFile + " ");

// connect(document(), SIGNAL(contentsChanged()),
// this, SLOT(documentWasModified()));
}
so I wrote in constructor mdi::newfile
is that right?

amagdy.ibrahim
15th June 2008, 10:19
Sorry

view = new QGraphicsView(Mdi->scene,MainWindow);

I have an error on this statement

amagdy.ibrahim
15th June 2008, 10:29
I tried this piece of code
view = new QGraphicsView(&(MdiChild::scene),MdiChild);

still error existed object missing reference to MdiChild::scence

error:from this location

please help me urgent

wysota
15th June 2008, 10:57
Please, take some book on C++ programming and learn at least basics of C++ first before starting with Qt. The code you wrote simply makes no sense from the syntax point of view.

amagdy.ibrahim
15th June 2008, 11:49
Thank you for your help,I need to view Qgraphics in Mdi child when I press on new dialog.I aleardy did this step which create Mdi widget.I wrote Qgprhics view in mainwindow.cpp when
I write this line: view = new QGraphicsView(&(MainWindow::scene),this);
qgraphics appears in mainwindow
so logicaclly I wrote this line to appear
view = new QGraphicsView(&(Mdi::scene),MainWindow);

wysota
15th June 2008, 11:56
&(Mdi::scene) - according to you what does this do?

amagdy.ibrahim
15th June 2008, 12:36
it is working nowww
Thanks :)

wysota
15th June 2008, 15:43
I rest my case... :eek: