Results 1 to 5 of 5

Thread: QSplitter and QStackedWidget

  1. #1
    Join Date
    Aug 2006
    Location
    troy, new york
    Posts
    24
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default QSplitter and QStackedWidget

    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.
    Last edited by nikita; 15th November 2006 at 04:32. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSplitter and QStackedWidget

    Add

    Qt Code:
    1. ...
    2. editor0->show();
    3. ...
    4. editor1->show();
    5. ....
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Aug 2006
    Location
    troy, new york
    Posts
    24
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QSplitter and QStackedWidget

    thanks but no go. still blank as ever...

  4. #4
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSplitter and QStackedWidget

    try this

    Qt Code:
    1. QSplitter *spl = new QSplitter(Qt::Vertical, this);
    2. spl->addWidget(editor0);
    3. spl->addWidget(editor1);
    4. QVBoxLayout *glayout = new QVBoxLayout(this);
    5. glayout->addWidget(spl);
    6. glayout->addWidget(label);
    7. setLayout(glayout);
    To copy to clipboard, switch view to plain text mode 

  5. The following user says thank you to munna for this useful post:

    nikita (15th November 2006)

  6. #5
    Join Date
    Aug 2006
    Location
    troy, new york
    Posts
    24
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QSplitter and QStackedWidget

    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...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.