View Full Version : Problem with setCentralWidget
blm
2nd September 2008, 12:44
I have in Konstruktor a setCentralWidget defined,
MainWin::MainWin()
{
plotter = new Plotter; //Plotter is a custom Widget
textEdit = new QTextEdit;
setCentralWidget(plotter);
}
in function changeToText(), and changeToPlotter(), I want to change the central Widget
so write:
MainWin::changeTotext()
{
setCentralWidget(textEdit);
}
MainWin::changeToPlotter()
{
setCentralWidget(plotter);
}
but at last i can`t change it, what`s wrong?:confused:
thanks for your help!
aamer4yu
2nd September 2008, 12:48
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 :)
blm
2nd September 2008, 13:11
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:
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
blm
2nd September 2008, 13:33
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
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.