Results 1 to 6 of 6

Thread: Q3CanvasRectangle table

  1. #1
    Join Date
    Mar 2007
    Posts
    16
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Smile Q3CanvasRectangle table

    i want to have a dynamic table of Q3CanvasRectangle elements inside but as this class does not have a constructor with 0 paramter, i cant create a table of these elements cause i should call one of the provided constructors and it is not possible while creating tables of objects.

    i also subclassed the Q3CanvasRectangle like this :

    Rectangle::Rectangle():Q3CanvasRectangle(0)
    {
    }

    and then i tried to create a table of Rectangle but i always get some moc erros
    Rectangle * tabRectangle; //class dynamique
    tabRectangle = new Rectangle[a value];

    can anyone help me, cause i must have a table of those Q3CanvasRectangles
    tnx

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Hi Everyone

    Use a table of pointers to objects instead of table to objects:
    Qt Code:
    1. Rectangle *tabRectangle[100];
    2. for(int i=0;i<100;i++)
    3. tabRectangle[i] = new Rectangle(...);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Mar 2007
    Posts
    16
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Q3CanvasRectangleTable

    tnx but this methode comes to what i had tried before, it does not solve my problem
    always moc error messages...

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Q3CanvasRectangleTable

    Moc shouldn't be ran here at all, as QCanvasRectangle doesn't inherit QObject. Can we see the complete definition of your Rectangle class?

  5. #5
    Join Date
    Mar 2007
    Posts
    16
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Q3CanvasRectangle table

    i have nothing inside the Rectangle() constructor, i just wanted to create a rectangle with a default constructor, i mean with no param that i could use to create tables of that Q3CanvasRectangle

    Clearly , i want to know if it is possible to have a container(list, vector, tables, whatever) of objects that does not provide a default constructor(0 parameter) and i assume that in that case we must call one of the provided constructors while creating our objects. so in my case i cant create for example a table of Q3CanvasRectangles
    like this:
    Q3CanvasRectangle tabRectangle[8];
    or
    Q3CanvasRectangle * tabRectangle;
    and later
    tabRectangle = new Q3CanvasRectangle[8];
    // no default constructor for Q3CanvasRectangle
    i hope u ve understand my problem tnx for the repiles

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Q3CanvasRectangle table

    1. For containers the contained type must have a default constructor.
    2. Using an array of canvas objects as opposed to array of pointers to canvas objects will likely cause a crash on exit.
    3. If moc scans your file, it means you have the Q_OBJECT macro there, so please tell us the error you get and show the content of the file it complains about (note that I was not asking for the constructor code but for the class definition).

Similar Threads

  1. Replies: 9
    Last Post: 21st June 2007, 10:27
  2. displaying any table on a qdatatable
    By Philip_Anselmo in forum Newbie
    Replies: 4
    Last Post: 9th May 2006, 22:12
  3. creating table plugin
    By mgurbuz in forum Qt Programming
    Replies: 3
    Last Post: 28th April 2006, 13:50
  4. Adding row in a Table after selected row
    By ankurjain in forum Qt Programming
    Replies: 3
    Last Post: 20th April 2006, 18:06
  5. Table model / view editing issue
    By Caius Aérobus in forum Qt Programming
    Replies: 9
    Last Post: 7th April 2006, 11:03

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.