Results 1 to 6 of 6

Thread: Arrays With Designer?

  1. #1
    Join Date
    Jul 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Arrays With Designer?

    Hi folks,

    does anyone know, how do create a QPushButton array with qDesigner?

    Example:

    int cnt = 20;
    QPushButton *butt[cnt];
    for ( int i = 0; i < cnt; i++) {
    butt[i] = new QPushButton("");
    ....
    }

    Can I do such a thing with Designer too?

    Thanks for any answers!

    Erich

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Arrays With Designer?

    the designer is only a tool for designing GUIs. You can't do this with designer. Why do you need it? You can get all push buttons later via qFindChild() or if you need an array for signal/slots normally a QSignalMapper is better than a list.

  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Arrays With Designer?

    Tell us what you are trying to do first, and we may be able to tell you an easier method.

  4. #4
    Join Date
    Jul 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Arrays With Designer?

    Hallo,

    thanks for your answers!

    I wrote a sudoku solver in C++ and now I'll try to give it a GUI. The solver works on an array of fields, each holding one number of a sudoku game. (Every field is an array by itself, so I have 3 dimensions.) My Problem is not, to write the GUI by hand. I look for a solution with QDesigner and I would like to include a 9x9 array of appropriate widgets in a QDesigner form.

    Erich

  5. #5
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Arrays With Designer?

    One way of doing that would be to drop an appropriate widget on the form (eg. a QLineEdit) and then using copy/paste to give 9 of that objects. Then you could copy those nine and paste 9 times to give you your 9x9 array. You can then easily place these into an array of pointers (to call there methods) as you'll know the names from what you type into the designer. To manage the signals, you can use a QSignalMapper which will inform you which widget the signal came from.

    There are other ways, but thats the first way that comes to mind if you want to use designer. Doing it in code wouldn't be much more difficult - you would just create the objects dynamically.

  6. #6
    Join Date
    Jul 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Arrays With Designer?

    Many thanks for your answers!

    I found an easy way by myself: I coded the array as a subclass (QFrame). Then I put a QFrame in the designer and used it as a placeholder for my own object. Now i have the array with propper indices (codet by hand) and the complete GUI in designer. It works!

    Erich

Similar Threads

  1. arrays + QtDesigner
    By p_t3r in forum Qt Tools
    Replies: 0
    Last Post: 8th December 2009, 00:33
  2. debugging arrays
    By divide in forum Qt Tools
    Replies: 1
    Last Post: 12th October 2009, 21:17
  3. QtScript and arrays
    By supergillis in forum Qt Programming
    Replies: 1
    Last Post: 20th May 2009, 19:13
  4. ActiveQt 2-dim arrays
    By nile.one in forum Qt Programming
    Replies: 1
    Last Post: 17th October 2007, 04:26
  5. creating 2-d arrays
    By therealjag in forum Newbie
    Replies: 1
    Last Post: 21st February 2006, 17:41

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.