Results 1 to 2 of 2

Thread: truncate my declaration of QGraphicsItem

  1. #1
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default truncate my declaration of QGraphicsItem

    i have QGraphicsItem()
    class GpioItem

    i want to add 28 item of it to add in the scene

    in the view.h
    i am adding like this
    Qt Code:
    1. GpioItem *button1;
    2. GpioItem *button2;
    3. GpioItem *button3;
    4. .
    5. .
    6. .
    7. .
    8. .
    9. GpioItem *button23;
    10. GpioItem *button24;
    To copy to clipboard, switch view to plain text mode 

    and the .h file becomes too lengthy ... how to define all the 28 items in a short way of coding c++ ...
    "Behind every great fortune lies a crime" - Balzac

  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: truncate my declaration of QGraphicsItem

    What's about
    Qt Code:
    1. private:
    2. QList<GpioItem *> m_items;
    3. //...
    4. //c-tor
    5. for (int i=0; i<24; ++i)
    6. {
    7. GpioItem *it = new GpioItem();
    8. // do some stuff with it
    9. m_items.append(it);
    10. scene->addItem(it);
    11. }
    12.  
    13. // access it via
    14. m_item.at(0)->setPos(...); //...
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to Lykurg for this useful post:

    wagmare (21st July 2009)

Similar Threads

  1. Replies: 2
    Last Post: 25th March 2011, 09:18
  2. static building qt, error: declaration of c function conflicts
    By BlueWizard in forum Installation and Deployment
    Replies: 4
    Last Post: 30th July 2010, 12:50
  3. destruction of QGraphicsItem
    By killkolor in forum Qt Programming
    Replies: 2
    Last Post: 5th December 2009, 10:31
  4. Replies: 1
    Last Post: 25th February 2009, 00:34
  5. problem with forward declaration
    By MarkoSan in forum General Programming
    Replies: 14
    Last Post: 6th January 2008, 21:45

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.