PDA

View Full Version : QSplitter and QStackedWidget



nikita
15th November 2006, 04:25
hi, the problem is that i have a page in within a stacked widget which won't show the first two widgets, maybe i've missed something in the docs or the forums:


QLabel *label = new QLabel(this);
label->setText("Compare Versions");
label->setFont(QFont("System", 12, QFont:: DemiBold));
label->setAlignment(Qt::AlignCenter);
QFile file0("in.txt");
if (!file0.open(QIODevice::ReadOnly | QIODevice::Text))
return;
QTextStream in0(&file0);
QString line0 = in0.readAll();
QTextEdit *editor0 = new QTextEdit(this);
editor0->setFontPointSize(16.0);
editor0->setFontWeight(QFont:: DemiBold);
editor0->setPlainText(line0);
QFile file1("ain.txt");
if (!file1.open(QIODevice::ReadOnly | QIODevice::Text))
return;
QTextStream in1(&file1);
QString line1 = in1.readAll();
QTextEdit *editor1 = new QTextEdit(this);
editor1->setFontPointSize(16.0);
editor1->setFontWeight(QFont:: DemiBold);
editor1->setPlainText(line1);
QSplitter spl(Qt::Vertical, this);
spl.addWidget(editor0);
spl.addWidget(editor1);
QVBoxLayout *glayout = new QVBoxLayout(this);
glayout->addWidget(&spl);
glayout->addWidget(label);
setLayout(glayout);





the label show()s, but not the editors. thanx.

munna
15th November 2006, 04:34
Add



...
editor0->show();
...
editor1->show();
....

nikita
15th November 2006, 04:39
thanks but no go. still blank as ever...

munna
15th November 2006, 04:42
try this




QSplitter *spl = new QSplitter(Qt::Vertical, this);
spl->addWidget(editor0);
spl->addWidget(editor1);
QVBoxLayout *glayout = new QVBoxLayout(this);
glayout->addWidget(spl);
glayout->addWidget(label);
setLayout(glayout);

nikita
15th November 2006, 04:52
that did the trick, i thought is was a who's your daddy?(parenting issue) but just needed to place on the heap. thanx again...