Results 1 to 7 of 7

Thread: reserve a space of a list

  1. #1
    Join Date
    Jun 2009
    Posts
    44
    Qt products
    Qt4
    Platforms
    Windows

    Default reserve a space of a list

    hey,

    I have created a list of qstring pointers without problems. But now, i want to make this list bigger and reseved some positions free.
    To get it, i have done this one:

    MENU *p1 = new MENU();
    TWO *p2 = new TWO();
    THREE *p3 = new THREE();
    FOUR *p4 = new FOUR();
    FIVE *p5 = new FIVE();
    SIX *p6 = new SIX();



    QList<QWidget*> list;
    list.insert(0,p1);
    list.insert(1,null);//free
    list.insert(2,null);//free
    list.insert(3,null);//free
    list.insert(4,null);//free
    list.insert(5,null);//free
    list.insert(6,null);//free
    list.insert(7,null);//free
    list.insert(8,null);//free
    list.insert(9,null);//free

    list.insert(10,p2);
    list.insert(11,null);//free
    list.insert(12,null);//free
    list.insert(13,null);//free
    list.insert(14,null);//free
    list.insert(15,null);//free
    list.insert(16,null);//free
    list.insert(17,null);//free
    list.insert(18,null);//free
    list.insert(19,null);//free

    list.insert(20,p3);
    list.insert(21,null);//free
    list.insert(22,null);//free
    list.insert(23,null);//free
    list.insert(24,null);//free
    list.insert(25,null);//free
    list.insert(26,null);//free
    list.insert(27,null);//free
    list.insert(28,null);//free
    list.insert(29,null);//free

    list.insert(30,p4);
    list.insert(31,null);//free
    list.insert(32,null);//free
    list.insert(33,null);//free
    list.insert(34,null);//free
    list.insert(35,null);//free
    list.insert(35,null);//free
    list.insert(37,null);//free
    list.insert(38,null);//free
    list.insert(39,null);//free

    list.insert(40,p5);
    list.insert(41,null);//free
    list.insert(42,null);//free
    list.insert(43,null);//free
    list.insert(44,null);//free
    list.insert(45,null);//free
    list.insert(46,null);//free
    list.insert(47,null);//free
    list.insert(48,null);//free
    list.insert(49,null);//free

    list.insert(50,p6);
    list.insert(51,null);//free
    list.insert(52,null);//free
    list.insert(53,null);//free
    list.insert(54,null);//free
    list.insert(55,null);//free
    list.insert(56,null);//free
    list.insert(57,null);//free
    list.insert(58,null);//free
    list.insert(59,null);//free

    But it dooesn't work! how can i reserve a space of this list free?

    thanks

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: reserve a space of a list

    you dont need to reserve any space... just insert the new items anywhere...
    but your code does not work because u are using "null" which i dont think is "0" .. try to insert number 0 or simply use a QWidget* free =0; and insert them.

  3. #3
    Join Date
    Jun 2009
    Posts
    44
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: reserve a space of a list

    iT doesn't work!
    I have triyed inserting 0 instead of Null and iT doesn't work, and i have trieyed too like this:

    QWidget* free =0;


    QList<QWidget*> list;
    list.insert(0,p1);
    list.insert(1,free);//free
    list.insert(2,free);//free
    list.insert(3,free);//free
    list.insert(4,free);//free
    list.insert(5,free);//free
    list.insert(6,free);//free
    list.insert(7,free);//free
    list.insert(8,free);//free
    list.insert(9,free);//free

    list.insert(10,p2);
    list.insert(11,free);//free
    list.insert(12,free);//free
    list.insert(13,free);//free
    list.insert(14,free);//free
    list.insert(15,free);//free
    list.insert(16,free);//free
    list.insert(17,free);//free
    list.insert(18,free);//free
    list.insert(19,free);//free

    list.insert(20,p3);
    list.insert(21,free);//free
    list.insert(22,free);//free
    list.insert(23,free);//free
    list.insert(24,free);//free
    list.insert(25,free);//free
    list.insert(26,free);//free
    list.insert(27,free);//free
    list.insert(28,free);//free
    list.insert(29,free);//free

    list.insert(30,p4);
    list.insert(31,free);//free
    list.insert(32,free);//free
    list.insert(33,free);//free
    list.insert(34,free);//free
    list.insert(35,free);//free
    list.insert(35,free);//free
    list.insert(37,free);//free
    list.insert(38,free);//free
    list.insert(39,free);//free

    list.insert(40,p5);
    list.insert(41,free);//free
    list.insert(42,free);//free
    list.insert(43,free);//free
    list.insert(44,free);//free
    list.insert(45,free);//free
    list.insert(46,free);//free
    list.insert(47,free);//free
    list.insert(48,free);//free
    list.insert(49,free);//free


    list.insert(50,p6);
    list.insert(51,free);//free
    list.insert(52,free);//free
    list.insert(53,free);//free
    list.insert(54,free);//free
    list.insert(55,free);//free
    list.insert(56,free);//free
    list.insert(57,free);//free
    list.insert(58,free);//free
    list.insert(59,free);//free

    the application run but the list doesn't work

  4. #4
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: reserve a space of a list

    can u tell what exactly does not work? this code compiles?

  5. #5
    Join Date
    Jun 2009
    Posts
    44
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: reserve a space of a list

    it compiles,i have set (in my application) that when it runs, it must show the menu screen.
    This screen has some buttons to go to two,three... sceens. So when I push in menu screen to go to another screen the aplication hide.

  6. #6
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: reserve a space of a list

    so this is not the problem of list.. this is something where you forgot to call show or even did not connected the signal... please provide a minimal compilable code for u to help you.

  7. #7
    Join Date
    Apr 2008
    Posts
    196
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    1

    Default Re: reserve a space of a list

    So, maybe you could use QStackedWidget for your Porblem.
    Or in your case, you can use a QVector instead:

    Qt Code:
    1. QWidget* free =0;
    2. QVector<QWidget*> vec(60, free);
    3. vec[0] = p1;
    4. vec[10] = p2;
    5. vec[20] = p3;
    6. vec[30] = p4;
    7. vec[40] = p5;
    8. vec[50] = p6;
    To copy to clipboard, switch view to plain text mode 

    Best Regards
    NoRulez

Similar Threads

  1. QFtp hidden files/folder's list
    By jay in forum Qt Programming
    Replies: 1
    Last Post: 26th December 2008, 12:12
  2. Replies: 2
    Last Post: 19th September 2008, 05:21
  3. Single slot for multiple list boxes
    By Sheetal in forum Qt Programming
    Replies: 1
    Last Post: 15th April 2008, 06:53
  4. Replies: 1
    Last Post: 22nd October 2007, 02:04
  5. linking user space and kernel space programs with qmake
    By zielchri in forum Qt Programming
    Replies: 9
    Last Post: 8th March 2006, 23:11

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.