Results 1 to 4 of 4

Thread: creating objects in a for()

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default creating objects in a for()

    Hi,

    I'm rather new to C++ and now I need a dynamic amount (int i) of buttons. I tried something (where I was sure that it wouldn't work, but just to tell you what I need) like this:
    Qt Code:
    1. int i; i=0;
    2. for(;i<9;i++){
    3. QLabel label(&fenster);
    4. label.setFrameStyle(QFrame::Panel | QFrame::Sunken);
    5. label.setText("first line\nsecond line");
    6. label.setAlignment(Qt::AlignTop | Qt::AlignLeft);
    7. label.setGeometry(10*i,80,120,50);
    8. }
    To copy to clipboard, switch view to plain text mode 

    I know that normally it would be my job to learn C++ properly, but perhaps you could be so kind and correct the code given above.

    Thanks.
    Last edited by phil_; 20th January 2006 at 19:16.

Similar Threads

  1. DAO or ORM or ?. objects <-> rdbms
    By darkadept in forum Qt Programming
    Replies: 4
    Last Post: 7th October 2010, 00:55
  2. objects modelling
    By mickey in forum General Discussion
    Replies: 1
    Last Post: 12th April 2008, 08:14
  3. Ole objects in Qt(MS OFFice)
    By mchara in forum Qt Programming
    Replies: 9
    Last Post: 26th September 2007, 07:07
  4. Custom objects in a QGraphicScene
    By draand in forum Qt Programming
    Replies: 2
    Last Post: 24th July 2007, 11:31
  5. Problem in creating thread in GUI application
    By jyoti kumar in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2006, 12:05

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.