Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, February 2007
[Qt3] QScrollView


Message 1 in thread

I want to provide a variable amount of QLineEdits in dialog and change
it adding/removing some.

I use QScrollView:

void SomeDialog::init(QWidget * page)
{
    QScrollView * view = new QScrollView( page );
    QVBox * box = new QVBox(view->viewport());
    view->addChild(box);

    QLineEdit * edit = new QLineEdit( box );
    edit->setText("c1");
    edit = new QLineEdit( box );
    edit->setText("c2");
    delete edit;
}

I've created 2 and then I've removed 1 so there's 1 QLineEdit left.

After a while I call this:

void SomeDialog::test( QVBox * thatBox )
{
        QLineEdit * edit = new QLineEdit(  thatBox );
        edit->setText("u1");
        edit = new QLineEdit( thatBox );
        edit->setText("u2");
        delete edit;
}

I've created 2 more and then I've removed 1 so there must be 2 QLineEdits.

But there's only one. test() don't cause any visible changes. Why?

--
 [ signature omitted ] 

Message 2 in thread

Hi,

try doing a show() after you create the new QLineEdit on your test() 
function. This updates qscrollview's childs and cause it to update the 
visible changes.
I know, it's a bit weird but some time ago I've been in the same situation.

Hope this helps.

Regards,
Javier

Dmitry Teslenko escribiÃ:
> I want to provide a variable amount of QLineEdits in dialog and change
> it adding/removing some.
>
> I use QScrollView:
>
> void SomeDialog::init(QWidget * page)
> {
>    QScrollView * view = new QScrollView( page );
>    QVBox * box = new QVBox(view->viewport());
>    view->addChild(box);
>
>    QLineEdit * edit = new QLineEdit( box );
>    edit->setText("c1");
>    edit = new QLineEdit( box );
>    edit->setText("c2");
>    delete edit;
> }
>
> I've created 2 and then I've removed 1 so there's 1 QLineEdit left.
>
> After a while I call this:
>
> void SomeDialog::test( QVBox * thatBox )
> {
>        QLineEdit * edit = new QLineEdit(  thatBox );
>        edit->setText("u1");
>        edit = new QLineEdit( thatBox );
>        edit->setText("u2");
>        delete edit;
> }
>
> I've created 2 more and then I've removed 1 so there must be 2 
> QLineEdits.
>
> But there's only one. test() don't cause any visible changes. Why?
>
> -- 
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>

--
 [ signature omitted ] 

Message 3 in thread

Hello!

> try doing a show() after you create the new QLineEdit on your test()
> function. This updates qscrollview's childs and cause it to update the
> visible changes.
> I know, it's a bit weird but some time ago I've been in the same situation.

I've added edit->show() and that helped. Thanks.

I don't know weird is it or not : I don't find anything in docs
concerning widget visibility after instantiation.
Maybe all widgets are hidden by default and only parent's show()
triggers their visibility. So if you create them in runtine, after
parent top-level widget are already shown, you're to show() them
manually.

--
 [ signature omitted ]