Results 1 to 10 of 10

Thread: Creating Qgraphics View code

  1. #1

    Default Creating Qgraphics View code

    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
    Qt Code:
    1. view = new QGraphicsView(&(MdiChild::newFile));
    2.  
    3. void MdiChild::newFile()
    4. {
    5. static int sequenceNumber = 1;
    6.  
    7. isUntitled = true;
    8. curFile = tr("document%1.txt").arg(sequenceNumber++);
    9. setWindowTitle(curFile + "[*]");
    10.  
    11. // connect(document(), SIGNAL(contentsChanged()),
    12. // this, SLOT(documentWasModified()));
    13. }
    To copy to clipboard, switch view to plain text mode 

    I have an error
    would you please help me?
    Last edited by wysota; 14th June 2008 at 17:35. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Creating Qgraphics View code

    Qt Code:
    1. view = new QGraphicsView(&(MdiChild::newFile));
    To copy to clipboard, switch view to plain text mode 
    This code seems invalid. What is MdiChild::newFile? What is the error you get?

  3. #3

    Default Re: Creating Qgraphics View code

    mainwindow.h:73:error expected ';' before '*'
    I need to create qgraphics in mdichild when I press on new button in the mainwindow
    Qt Code:
    1. void MdiChild::newFile()
    2. {
    3. static int sequenceNumber = 1;
    4.  
    5. isUntitled = true;
    6. curFile = tr("document%1.txt").arg(sequenceNumber++);
    7. setWindowTitle(curFile + "[*]");
    8.  
    9. // connect(document(), SIGNAL(contentsChanged()),
    10. // this, SLOT(documentWasModified()));
    11. }
    To copy to clipboard, switch view to plain text mode 
    so I wrote in constructor mdi::newfile
    is that right?
    Last edited by jpn; 27th June 2008 at 19:53. Reason: missing tags

  4. #4

    Default Re: Creating Qgraphics View code

    Sorry

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

    I have an error on this statement

  5. #5

    Default Re: Creating Qgraphics View code

    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

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Creating Qgraphics View code

    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.

  7. #7

    Default Re: Creating Qgraphics View code

    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);

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Creating Qgraphics View code

    &(Mdi::scene) - according to you what does this do?

  9. #9

    Default Re: Creating Qgraphics View code

    it is working nowww
    Thanks

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Creating Qgraphics View code

    I rest my case...

Similar Threads

  1. Not Scaling QBrush style fro qgraphics view item
    By dan in forum Qt Programming
    Replies: 8
    Last Post: 20th September 2013, 20:56
  2. Model-view: Creating a custom view
    By taboom in forum Qt Programming
    Replies: 5
    Last Post: 17th August 2007, 20:36
  3. problem with linking
    By mickey in forum Qt Programming
    Replies: 49
    Last Post: 12th August 2006, 21:41
  4. Creating a global array in my code???
    By therealjag in forum General Programming
    Replies: 5
    Last Post: 13th March 2006, 11:13

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.