PDA

View Full Version : QTextEdit and Painter problems



Rooster
3rd August 2008, 02:04
I have a series of widgets that I use to draw a series of graphs on them. I also have it set up to show and hide the graph widgets. When the widgets are shown or hidden all the graph widgets resize to fit the new widget.

However I wanted to add a QTextEdit widget so that I might be able to display some information. However, when I add the QTextEdit widget to the main qui, when I try to hide a widget and then resize the others all of the widgets disappear.

Can anyone help me understand what is going on or give me some suggestions as to why this is happening.

Here is some code if you need to see how I have things set up.


bla::bla(QWidget *parent) : QWidget(parent)
{
mainlayout = new QVBoxLayout(this);
bottomlayout = new QHBoxLayout;
buttonlayout = new QVBoxLayout;
textlayout = new QVBoxLayout;

real_chart = new Chart(this);
synth_chart = new Chart(this);
ident_chart = new Chart(this);

real_button = new QPushButton(this);
real_button->setText("Real");

synth_button = new QPushButton(this);
synth_button->setText("Synthetic");

ident_button = new QPushButton(this);
ident_button->setText("Identify");

log = new QTextEdit(this);
log->setReadOnly(true);
log->setMaximumHeight(100);

textlayout->addWidget(log);

buttonlayout->addWidget(real_button);
buttonlayout->addWidget(synth_button);
buttonlayout->addWidget(ident_button);
buttonlayout->addLayout(textlayout);
}

//this is some sudo code for what the slots look like for each of the buttons
void bla::buttonpush()
{
if(widget->isVisible() == false)
{
widget->show();
resize(width,height);
}
else
{
widget->hide();
resize(width,height);
}
}

//this is what this function does in a nutshell
//works perfectly until the QTextEdit widget is inserted
void bla::resize(int width, int height)
{
//get the height and width of the layout
// divide the height by the number shown widgets
//resize each widget that is shown to the correct width and height
}