Results 1 to 20 of 24

Thread: Adding item to GridLayout???

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    14
    Thanked 4 Times in 4 Posts

    Default Adding item to GridLayout???

    Hi..

    I have created a canvas and have given it a grid layout... Now i want to add items to it...

    But the addItem() function takes a QLayoutItem to be added..
    I want to add a Q3CanvasLine object to the first row and column but am not able to do so...

    How do i do that.. i tried to create a QLayoutItem with a QCanvasLine object but it wasn't created.. what is the procedure to do it...

    Thanking you,

    with regards,
    Kapil

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    10
    Thanked 80 Times in 74 Posts

    Default Re: Adding item to GridLayout???

    I don't think you can add a canvas item to a layout.

  3. #3
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    14
    Thanked 4 Times in 4 Posts

    Default Re: Adding item to GridLayout???

    Quote Originally Posted by munna
    I don't think you can add a canvas item to a layout.
    But i was able to sucessfully set up grid layout for the canvas... and its returning the rowCount and columnCount as well...

    can't there be any way in which i can typecast my canvasitem to layoutitem and then add it?????

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

    Default Re: Adding item to GridLayout???

    No. Canvas doesn't work that way. It doesn't use layouts.

  5. #5
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    14
    Thanked 4 Times in 4 Posts

    Default Re: Adding item to GridLayout???

    Quote Originally Posted by wysota
    No. Canvas doesn't work that way. It doesn't use layouts.
    Aaahhhhhh

    Thanks for the reply...

    Is there any way to work like a layout works... i.e. while creating items i want them to specify them in a particular region.. like a rectangular region which would contain set of items independent from the other regions... i can work on these group of items in a particular rectangular region as a whole.. like moving the entire region to other part..
    or like making a copy of the entire region and repeating it multiple times (like normal copy and paste types)...

    is there any way out for this ?????
    All you have to decide is what to do with the time that is given to you

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

    Default Re: Adding item to GridLayout???

    Try with an article on Qt Quarterly -- Canvas Item Groupies.

  7. #7
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    14
    Thanked 4 Times in 4 Posts

    Default Re: Adding item to GridLayout???

    Hey...

    Thanks a lot.. it was able to group similar elements together and now i can act on them as a whole single item...

    One problem is still there.. to perform the copy and paste task, i.e. to create multiple instances of the object and then place them one after another on the canvas... what i did was that i copied the object information into another object and tried to place it.. but now it is just overwriting it on the current location.. now it contains the same pixel information and is overwriting it... How do i change that information to new location information ????

    How do i perform the copy n paste task ???

    Should i put in the code of mine which i wrote to perform the copy n paste to make it more clear????
    All you have to decide is what to do with the time that is given to you

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

    Default Re: Adding item to GridLayout???

    Quote Originally Posted by Kapil
    One problem is still there.. to perform the copy and paste task, i.e. to create multiple instances of the object and then place them one after another on the canvas... what i did was that i copied the object information into another object and tried to place it.. but now it is just overwriting it on the current location.. now it contains the same pixel information and is overwriting it... How do i change that information to new location information ????
    Maybe you should just... move it?

    How do i perform the copy n paste task ???
    I believe this topic is widely described in the documentation.

  9. #9
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    14
    Thanked 4 Times in 4 Posts

    Default Re: Adding item to GridLayout???

    Quote Originally Posted by wysota
    Maybe you should just... move it?
    moving it, shifts the group to some other part of the canvas... but does not replicate it...
    i want to create many copies of it all over the place...

    I went thru the doc carefully.. but it talked abt adding,moving,deleting, merging.... It tells me to create a group by clubbing the elemnts but does not tell me to recreate elements from that group at different location...

    that is the problem which is there...

    sorry, but any function of CanvasGroup class in the doc was not able to give me a bit of info on how to perform copy and paste on a group of elements...

    Thanks,

    Kapil
    All you have to decide is what to do with the time that is given to you

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

    Default Re: Adding item to GridLayout???

    Quote Originally Posted by Kapil
    sorry, but any function of CanvasGroup class in the doc was not able to give me a bit of info on how to perform copy and paste on a group of elements...
    I wasn't talking about canvas group. I was talking about clipboard mechanisms present in Qt. If you paste a group, you naturally have to make a copy of each element in it as new instances, make a new group and insert those elements in the group. All according to the mime information present in the clipboard object.

  11. #11
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    14
    Thanked 4 Times in 4 Posts

    Default Re: Adding item to GridLayout???

    hi..

    i went through the documentation of QClipboard, QMimeData and QByteArray...
    as per what i understood this is what i have to do..

    CanvasGroup *canvasgp = new CanvasGroup;
    //Then i create the entire group
    QByteArray *barr = new QByteArray(1);
    barr[0] = canvasgp;
    QMimeData *mime = new QMimeData;
    mime->setData("Canvas Group",&barr);
    clipboard->setMimeData(mime,mode);

    is this approach correct.. basically this is first time i am dealing with it and as well learning all these concepts as you know.. so i might seem to make disasterous mistakes as well..
    sorry for asking you so many questions..

    Thanks,
    Kapil
    All you have to decide is what to do with the time that is given to you

Similar Threads

  1. ListWidget positions item
    By talex in forum Qt Programming
    Replies: 3
    Last Post: 21st October 2008, 16:16
  2. View, Scene, Item and thread??
    By dungsivn in forum Qt Programming
    Replies: 5
    Last Post: 20th August 2008, 20:21
  3. Item in a DLL not getting events
    By Benne Gesserit in forum Qt Programming
    Replies: 11
    Last Post: 16th August 2008, 23:30
  4. Item Delegate Painting
    By stevey in forum Qt Programming
    Replies: 3
    Last Post: 9th May 2008, 08:37
  5. Replies: 1
    Last Post: 19th April 2007, 23:23

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.