PDA

View Full Version : problem in widget inheritance



wagmare
9th December 2008, 10:50
i created one object "main" with stackedwidget where there is four pages and in four pages i create three "panel" classes

MainWindow ::MainWindow(QDialog *parent)
{
Panel *panel = new Panel();
}
now in panel.cpp a Qpushbutton "control" ... if i click the pushbutton of panel class can i change the page of the main class stackedWidget
i am having less C++ knowledge
please help

lyuts
9th December 2008, 13:02
Give us more code.

wagmare
10th December 2008, 07:35
in program
mainwindow.cpp
designer: mainwindow.ui--> Qstackedwidget having pages 4;
in each page a 'frame' say frame1, frame 2,frame 3, frame 4;
beside the stacked widget three 'pushbutton' say pButton1,pButton2,pButton3
so constructing

class MainWindow : public QDialog, public Ui::MainWindow
setupUi(this) ;

connect(pButton1 , SIGNAL(clicked()), this, SLOT(nextPage1()));
void MainWindow::nextPage1()
{
stackedWidget->setCurrentIndex(0);
}

connect(pButton2 , SIGNAL(clicked()), this, SLOT(nextPage2()));
void MainWindow::nextPage2()
{
stackedWidget->setCurrentIndex(1);
}

connect(pButton1 , SIGNAL(clicked()), this, SLOT(nextPage3()));
void MainWindow::nextPage3()
{
stackedWidget->setCurrentIndex(4);
}

/*so if we click the three buttons the stack widget will change the pages - right!*/

now
in same mainwindow.cpp

#include "panel.h" /* an external program */
Panel *panel = new Panel();

QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(panel);
frame1->setLayout(layoout);
/*so now the panel will be loaded to the page 1 --right! * /

this is the setup in mainwindow.cpp program

in panel.cpp
designer: subwindow.ui ->three pushbuttons say subButton1,subButton2,subButton3
so constricting

class Panel2 : public QDialog, public Ui::SubWindow
setupUi(this)


this is my program looks like
in mainwindow
clicking pButton1->stackedWidget->page1
clicking pButton2->stackedWidget->page2
clicking pButton3->stackedWidget->page3

now i want
in panel
clicking subButton1->stackedWidget(mainwindow's)->page4
that is i have to change the mainwindow's stackedwidget page from clicking panel's subButton1

this is my problem how can i solve it "please help me":crying: