Results 1 to 10 of 10

Thread: graph to be appear on same window

  1. #1
    Join Date
    Mar 2011
    Posts
    51
    Qt products
    Qt3 Qt4 Qt/Embedded
    Thanks
    7

    Default graph to be appear on same window

    hello every one i want to ask a question that i have a form in which their is a list box and a a button i select value from list box and press button the 2 graph appears in a new window i have make the graph window appear using show() funtion

    what i want is , graph should appear on my main form i will already alot some space in my main window which is first empty but when i click the buttton graph appears on it



    hope u people got my question any help will be appreciated

    thanks so much

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    8
    Thanked 133 Times in 128 Posts

    Default Re: graph to be appear on same window

    make the window which contains the graph, the child of your main window. then just call update().

  3. #3
    Join Date
    Mar 2011
    Posts
    51
    Qt products
    Qt3 Qt4 Qt/Embedded
    Thanks
    7

    Default Re: graph to be appear on same window

    thanks so much can u guide me little more thanks

  4. #4
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    8
    Thanked 133 Times in 128 Posts

    Default Re: graph to be appear on same window

    tell me what you are stuck at.

  5. #5
    Join Date
    Mar 2011
    Posts
    51
    Qt products
    Qt3 Qt4 Qt/Embedded
    Thanks
    7

    Default Re: graph to be appear on same window

    ok sir i will tell u in my program i have a widget window i have places a button an a list box in it. then i have made a class called myplot. i which graph plotting is done . then i n my button event handler i have called the object of myplot

    Qt Code:
    1. myplot * p1 = new myplot(session,session ,24, "session"); // send arrays in argument containing the data to be plot
    2. p1->show();
    3. myplot * p2 = new myplot(payload,payload ,24, "payload"); // send arrays in argument containing the data to be plot
    4. p2->show();
    To copy to clipboard, switch view to plain text mode 


    it working fine as my graph appear in new window. but what i want is that graphs should appear in my mainwigget window .

    next what i did is that to remove the title bar of my graphs window i wrote
    Qt Code:
    1. p1->setWindowFlags(Qt::FramelessWindowHint);
    2. p2->setWindowFlags(Qt::FramelessWindowHint);
    To copy to clipboard, switch view to plain text mode 

    now

    1) what should i do to place and append the graphs window in my main window. also when i close main window my graph window should close .
    2) when i select an other value from the list box and click button my old graph disappear and new should appear

    hope you got me

    thanks

  6. #6
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo
    Thanks
    1
    Thanked 26 Times in 26 Posts

    Default Re: graph to be appear on same window

    You must make p1 and p2 a child widget of your main window. So:

    If your main window is created in a similar way as below:

    Qt Code:
    1. QPushButton *button = new QPushButton;
    2.  
    3. QVBoxLayout *mainLayout = new QVBoxLayout;
    4. mainLayout ->addWidget(button);
    5. mainLayout ->addWidget(list);
    6.  
    7. QWidget* mainWindow = new QWidget;
    8. mainWindow->setLayout(mainLayout );
    9.  
    10. mainWindow.show();
    To copy to clipboard, switch view to plain text mode 

    Then the only thing you have to do is this:

    Qt Code:
    1. myplot * p1 = new myplot(session,session ,24, "session"); // send arrays in argument containing the data to be plot
    2. mainLayout->addWidget(p1);
    To copy to clipboard, switch view to plain text mode 

    However If I were you I would place a QScrollArea inside your layout and then place your plots in there.

  7. #7
    Join Date
    Mar 2011
    Posts
    51
    Qt products
    Qt3 Qt4 Qt/Embedded
    Thanks
    7

    Default Re: graph to be appear on same window

    sir i have drag and drop the list box and button........


    Added after 1 2 minutes:


    sir i have written layout->addwidget(p1) but its giving me error that

    /usr/include/qt4/QtGui/qlayout.h:191: error: ‘void QLayout::addChildWidget(QWidget*)’ is protected

    what should i do .


    also plz tell me ho to use scroll area as it is not giving me option for function addwidget


    thanks
    Last edited by maarvi; 17th June 2011 at 10:28.

  8. #8
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    8
    Thanked 133 Times in 128 Posts

    Default Re: graph to be appear on same window

    provide a minimal compilable example reproducing the problem. Its very hard for us to make u understand because it looks like you are very new to Qt.

  9. The following user says thank you to nish for this useful post:

    maarvi (17th June 2011)

  10. #9
    Join Date
    Mar 2011
    Posts
    51
    Qt products
    Qt3 Qt4 Qt/Embedded
    Thanks
    7

    Default Re: graph to be appear on same window

    yes sir this is my first program in Qt and i am facing too much difficulty.
    sir my problem is same now i have drag and drop a scroll area in my gui.

    now in my button event handler code i wrote the code


    Qt Code:
    1. myplot * p1 = new myplot(session,session ,24, "session");
    2. p1->setWindowFlags(Qt::FramelessWindowHint);
    3. ui->scrollArea->addScrollBarWidget(p1,0);
    4. p1->show();
    To copy to clipboard, switch view to plain text mode 

    upon running the program my graph did not appear what could be the problem i am not getting..... :'(
    please help me i will be very thank full


    Added after 1 9 minutes:


    thank u sir my graph has appeared on the layout....
    Last edited by maarvi; 17th June 2011 at 15:02.

  11. #10
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo
    Thanks
    1
    Thanked 26 Times in 26 Posts

    Default Re: graph to be appear on same window

    That is your problem:

    Quote Originally Posted by maarvi View Post
    Qt Code:
    1. ui->scrollArea->addScrollBarWidget(p1,0);
    To copy to clipboard, switch view to plain text mode 
    You must use:
    Qt Code:
    1. ui->scrollArea->setWidget(p1);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 1
    Last Post: 2nd May 2011, 10:12
  2. Replies: 2
    Last Post: 17th February 2011, 12:30
  3. graph
    By sonu111 in forum Qwt
    Replies: 1
    Last Post: 15th December 2008, 22:14
  4. graph drawing
    By swathi in forum Qt Programming
    Replies: 1
    Last Post: 8th November 2008, 09:27

Tags for this Thread

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.