Problem with setCentralWidget
I have in Konstruktor a setCentralWidget defined,
Code:
MainWin::MainWin()
{
plotter = new Plotter; //Plotter is a custom Widget
setCentralWidget(plotter);
}
in function changeToText(), and changeToPlotter(), I want to change the central Widget
so write:
Code:
MainWin::changeTotext()
{
setCentralWidget(textEdit);
}
MainWin::changeToPlotter()
{
setCentralWidget(plotter);
}
but at last i can`t change it, what`s wrong?:confused:
thanks for your help!
Re: Problem with setCentralWidget
How are u calling the changeToText and changeToPLotter functions ??
I am not sure if you can set central widget twice.
You may try this - set a QStackedWidget as central widget for the main window, and on the changeToText and changeToPLotter functions, set the text or plotter as the widget :)
Re: Problem with setCentralWidget
Quote:
Originally Posted by
aamer4yu
How are u calling the changeToText and changeToPLotter functions ??
I am not sure if you can set central widget twice.
You may try this - set a QStackedWidget as central widget for the main window, and on the changeToText and changeToPLotter functions, set the text or plotter as the widget :)
I call them like this:
Code:
Void MainWin::creatActions()
{
...
connect(newAct, SIGNAL(triggered()), this, SLOT(changeToText()));
...
}
it`s a litte complex,
now i can see the TextEditor Window, if i call changeToText,
but if i call changeToPlotter further, got a error Message..:confused:
QStackedWidget is a good idea, i will try it .thanks
Re: Problem with setCentralWidget
Quote:
Originally Posted by
aamer4yu
You may try this - set a QStackedWidget as central widget for the main window, and on the changeToText and changeToPLotter functions, set the text or plotter as the widget :)
hallo friend!
now it Works! Thanks a lot! :D