View Full Version : graph to be appear on same window
maarvi
17th June 2011, 07:28
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
nish
17th June 2011, 07:39
make the window which contains the graph, the child of your main window. then just call update().
maarvi
17th June 2011, 07:51
thanks so much can u guide me little more thanks
nish
17th June 2011, 08:47
tell me what you are stuck at.
maarvi
17th June 2011, 10:00
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
myplot * p1 = new myplot(session,session ,24, "session"); // send arrays in argument containing the data to be plot
p1->show();
myplot * p2 = new myplot(payload,payload ,24, "payload"); // send arrays in argument containing the data to be plot
p2->show();
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
p1->setWindowFlags(Qt::FramelessWindowHint);
p2->setWindowFlags(Qt::FramelessWindowHint);
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
Rachol
17th June 2011, 10:17
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:
QListWidget *list = new QListWidget;
QPushButton *button = new QPushButton;
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout ->addWidget(button);
mainLayout ->addWidget(list);
QWidget* mainWindow = new QWidget;
mainWindow->setLayout(mainLayout );
mainWindow.show();
Then the only thing you have to do is this:
myplot * p1 = new myplot(session,session ,24, "session"); // send arrays in argument containing the data to be plot
mainLayout->addWidget(p1);
However If I were you I would place a QScrollArea inside your layout and then place your plots in there.
maarvi
17th June 2011, 11:28
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
nish
17th June 2011, 13:01
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.
maarvi
17th June 2011, 16:02
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
myplot * p1 = new myplot(session,session ,24, "session");
p1->setWindowFlags(Qt::FramelessWindowHint);
ui->scrollArea->addScrollBarWidget(p1,0);
p1->show();
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.... :D
Rachol
17th June 2011, 16:06
That is your problem:
ui->scrollArea->addScrollBarWidget(p1,0);
You must use:
ui->scrollArea->setWidget(p1);
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.