Am Fri, 24 Mar 2017 10:52:47 +0100
schrieb Jean-Michaël Celerier <jeanmichael.celer...@gmail.com>:

> On Fri, Mar 24, 2017 at 12:50 AM, Thiago Macieira <thiago.macie...@intel.com
> > wrote:  
> 
> >
> > The new value is already carried by the signal. We don't need the getter:
> > my
> > code examples already compile.
> >  
> 
> I really think that we do.
> 
> For instance in the following code:
> 
> #include <QApplication>
> #include <QLabel>
> #include <QVBoxLayout>
> #include <QLineEdit>
> int main(int argc, char *argv[])
> {
>   QApplication a(argc, argv);
> 
>   QWidget w;
>   QVBoxLayout lay;
>   QLabel label;
>   QLineEdit text{"Some text"};
>   lay.addWidget(&label);
>   lay.addWidget(&text);
> 
>   QObject::connect(&text, &QLineEdit::textChanged,
>           &label, &QLabel::setText);
> 
>   w.setLayout(&lay);
>   w.show();
> 
>   return a.exec();
> }
> 
> when running the application, the label has no text, and takes the
> lineedit's text only when the lineedit changes.

for qt applications i normally have saveState and restoreState methods, 
which will save/restore the current widget and all of relevant child states, 
like your QLineEdit.
so when restoring the current widgets state, e.g. during construction of the 
widget itself,
the update is triggered, and you'll see the text in the lable right away.

or, i think, when you do:

  // ...
  w.show();
  text.setText("Some text")

instead of
  QLineEdit text{"Some text"};
  //...
  w.show();

should give you the same result.

in the end,
i think qml hides this implementation details, so you don't have to think about 
the mechanisms behind this.

alex

-- 
/*
 *Q:  What do you get when you cross a mobster with an international standard?
 *A:  You get someone who makes you an offer that you can't understand!
 */

Attachment: pgp9fS6fbNmKU.pgp
Description: Digitale Signatur von OpenPGP

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to