Results 1 to 5 of 5

Thread: EDITED: Representing an Array REDUX!!!!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2009
    Location
    Southern California
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question EDITED: Representing an Array REDUX!!!!

    Hello,
    I've got the official book: http://qt.nokia.com/developer/books/...-4-2nd-edition, but I've come to part where I'm not sure which way to go.

    I've got an array of 100 integers that are 3 integers long. I've setup my inputmasks on my lineEdits to be able to control this, so data sanitation is already handled. I'm trying to figure out the best way to both display this data, as well as edit it.

    • Is it possible to create pointers of lineEdits, put them in a QList container, and display them as well as access them through for() loops?
    • Is it possible to create an array within another class, and simply have 100 line edits point to said array. lineEdit00 points to numbers[0]?
    • Am I missing something?


    Any help would be great. Thanks for such a nice forum to ask questions.
    -bobby

    Qt Code:
    1. for(int i = 0; i < 100; i++)
    2. {
    3. // Setup the proper label
    4. if( i < 10)
    5. {
    6. labelPtr = new QLabel(tr("0%1").arg(i));
    7. }else{
    8. labelPtr = new QLabel(tr("%1").arg(i));
    9. }
    10.  
    11. // Now the Address Cell
    12. lePtr = new QLineEdit();
    13. lePtr->setInputMask("999");
    14. // if it's cell 00 make uneditable
    15. if(i < 1)
    16. {
    17. lePtr->setText("001");
    18. lePtr->setReadOnly(true);
    19. }
    20. memAddr.append(lePtr);
    21.  
    22. }
    23.  
    24. // Fill in the layout and display it
    25. for( int i = 0; i < 100; i++)
    26. {
    27. layout->addWidget(memAddr.at(i));
    28. }
    29.  
    30. window->setLayout(layout);
    31. window->show();
    To copy to clipboard, switch view to plain text mode 
    EDIT:
    Ok so I put my line edits into a QList, and I'm going to call them. my idea is that I have to use a forloop similar to the one I did, but with the addition to the labels as well.
    I really need to know how to take something like this that I pulled off, and put it into my application. Do I stick everything into the mainWindow.cpp (implementation) or do I make a new class, I really don't know.

    Another thought is to promote a groupbox into a "myGroupBox" and have the code run in there, but I'm really not clear how to do that, even with the help of Google.

    -Bobby
    Last edited by bobby; 16th November 2009 at 00:46. Reason: Additional Information

Similar Threads

  1. Accessing array in both C++ and QtScript
    By abernat in forum Qt Programming
    Replies: 10
    Last Post: 6th September 2009, 22:21
  2. Problems passing an array of pointers to objects to a function
    By Valheru in forum General Programming
    Replies: 16
    Last Post: 30th June 2008, 00:11
  3. Problem in converting QString to QChar array?
    By KaKa in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2007, 00:38
  4. How to create QPixmap from unsigned character array?
    By rashidbutt in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 18:25
  5. QSettings again ... how to remove array elements
    By Mike in forum Qt Programming
    Replies: 4
    Last Post: 11th January 2006, 08:58

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.