Results 1 to 9 of 9

Thread: Creating an Array of Button

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2011
    Posts
    25
    Qt products
    Qt/Embedded
    Platforms
    Symbian S60

    Default Creating an Array of Button

    hello friends

    I am creating an array of buttons having 7 rows 7 colums..
    now i trying to display first seven buttons in one row after which it goes to second row and display next seven button..and so on..

    i have wrriten a code for this..its working but problem is that all the buttons are displayed in one row only..so if anyone suggest me to resolve that problem..

    i am sending my code along with this..

    Qt Code:
    1. QWidget *centralWidget = new QWidget;
    2. selectedDate=QDate::currentDate();
    3. int count=1,i,j;
    4. QPushButton *button[10][10];
    5. QHBoxLayout *controlsLayout = new QHBoxLayout;
    6. for(i=0;i<7;i++)
    7. {
    8. for(j=0;j<7;j++)
    9. {
    10. if(count<=42)
    11. {
    12.  
    13.  
    14. button[i][j] = new QPushButton("p");
    15.  
    16. button[i][j]->resize(40,40);
    17.  
    18. button[i][j]->move(40*j, 40*i);
    19.  
    20. button[i][j]->show();
    21.  
    22. controlsLayout->addWidget(button[i][j]);
    23.  
    24. centralWidget->setLayout(controlsLayout);
    25.  
    26. setCentralWidget(centralWidget);
    27.  
    28. count++;
    29. }
    30.  
    31. }
    32.  
    33. }
    34.  
    35. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by high_flyer; 21st April 2011 at 15:04. Reason: code tags

Similar Threads

  1. Array of button for creating custom calender
    By anshumanBorah in forum Qt Programming
    Replies: 1
    Last Post: 12th April 2011, 13:21
  2. Creating a style for a button
    By Luc4 in forum Qt Programming
    Replies: 2
    Last Post: 23rd April 2010, 13:16
  3. Creating a button programmatically
    By Luc4 in forum Newbie
    Replies: 1
    Last Post: 27th January 2010, 10:30
  4. Creating a Pixmap out of an array of data
    By toratora in forum Qt Programming
    Replies: 2
    Last Post: 5th June 2007, 19:00
  5. Creating a global array in my code???
    By therealjag in forum General Programming
    Replies: 5
    Last Post: 13th March 2006, 11:13

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.