Results 1 to 2 of 2

Thread: foreach QTextEdit in Layout

  1. #1
    Join Date
    Sep 2010
    Posts
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60

    Default foreach QTextEdit in Layout

    I dynamically added QTextEdit items in a particular layout (QGrigLayout).
    Later I want to to extract the values of each QTextEdit item and merge them into a single QString.

    Any thoughts?

    The following does not work:
    QString msg;
    QLayoutItem *item;
    foreach (item, ui->toPlainText)
    {
    msg+= item->text();
    }
    Last edited by slc; 2nd September 2010 at 00:02.

  2. #2
    Join Date
    Sep 2010
    Posts
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60

    Default Re: foreach QTextEdit in Layout

    Ok I did the following as a work around (is there a better method?):

    // Create a list of QTextEdit
    QList<QTextEdit *> list;

    // Everytime I create a new QTextEdit, I add it to the 'list'
    QTextEdit *qe = new QTextEdit();
    pageEdits.append(qe);


    // Then I iterate through the list:
    QString combined;
    foreach (QTextEdit *q, list)
    {
    combined.append(q->toPlainText());
    }

Similar Threads

  1. Replies: 6
    Last Post: 5th May 2010, 23:25
  2. lifetime of foreach
    By BalaQT in forum Newbie
    Replies: 4
    Last Post: 4th March 2010, 15:55
  3. Replies: 2
    Last Post: 6th February 2010, 16:31
  4. Adjust the initial size of a QTextEdit in a layout
    By hecinho in forum Qt Programming
    Replies: 0
    Last Post: 26th November 2009, 15:58
  5. Foreach performance
    By jano_alex_es in forum General Programming
    Replies: 2
    Last Post: 17th November 2009, 13:26

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.