Results 1 to 7 of 7

Thread: QCanvas Examples

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

    Default QCanvas Examples

    Hi,

    Can anyone please tell me how do we use QCanvas inplace of QWidget or QMainWindow and suggest me few programming examples on how to use QCanvas.

    thanking you,
    Kapil

  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: QCanvas Examples

    You don't use QCanvas "in place" of QWidget (or any of its descendants). QCanvas is a mechanism to operate on double buffered objects which get displayed using QCanvasView. What kind of examples do you want? You have some examples in Qt docs. Aren't they enough?

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

    Default Re: QCanvas Examples

    Quote Originally Posted by wysota
    You don't use QCanvas "in place" of QWidget (or any of its descendants). QCanvas is a mechanism to operate on double buffered objects which get displayed using QCanvasView. What kind of examples do you want? You have some examples in Qt docs. Aren't they enough?
    Hi,

    What are double buffered objects???? i couldn't understand that

    I want Image Managing and Tiles Creation example related to QCanvas.. There are quite a lot of examples there and are real good ones but none use QCanvas and are not even a bit close to the examples i want...

    thanking you,

    Kapil

  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: QCanvas Examples

    The first question is -- why do you want to use QCanvas at all?
    The second one is -- why do you want to use QCanvas if you don't even know what it does?

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

    Default Re: QCanvas Examples

    hi..

    I want to use QCanvas because ->
    I have a BIG Design file from which a BIG Design Image with rectangles, lines and circles is created dynamically... Now when i create it and show it, it takes lots of time..
    I want my execution time to be very less.. So I thought of generating only that part of the image which can be seen on the screen... when the user moves the scrollbar top-down or left-right, that part of the image is created that comes in display...All this happens dynamically with the Scroll Bar events... Now i had put up a query for the same and got the reply to use QCanvas which handles the things in a similar manner..
    I created few applications using QCanvas and QCanvasView and they got executed well..Now there is a function called setTiles() which helps me show only those tiles which are currently in display and the moment the scroll bar movement happens, it captures those events and paints the new tiles.. Thus i have divided my design into smaller number of tiles and want to execute it in the same way... This is what i want to do....
    But then am not getting enough examples which could tell me dynamic creation of that part of image which would be in display only...
    I hope i have been able to convey you what i want....
    Now if there is some other way also to solve the problem then plz tell me, i would be thabkful to you 'coz its been just 1 month since i have started using it... I dont know how to use it but why not trying it out and knowing it..
    The problems is similar to the query i had put up in the Viewport thread...

    Thanking you,
    Kapil

  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: QCanvas Examples

    With QCanvas you shouldn't generate only "a part" of display. QCanvas approach is to be used when you have persistent objects which are generated once and then redrawn when needed by QCanvas mechanism. If an object doesn't fit on the viewport, it won't be drawn. Everything is double buffered, meaning that the actual drawing takes place of screen and is then just rendered on the widget (and only those parts which are considered "dirty") which makes drawing faster and without flicker. It also allows easy access to a particular object in case you want to implement selecting or moving them.

    When using QCanvas you should focus on each particular object separately -- don't "look" at all of them at once. Based on this, there is no "part which is visible". There is no dynamic creation of objects -- this breaks down everything that makes QCanvas fast. Please remember it is not a general use drawing canvas. There is the QPainter approach for that.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QCanvas Examples

    Quote Originally Posted by Kapil
    But then am not getting enough examples which could tell me dynamic creation of that part of image which would be in display only...
    You shouldn't need this, if your whole design can be represented as QCanvasItems which fit in memory.

    If you can't fit your design in memory, then you should rather subclass QWidget and implement such functionality yourself. For example using spatial index like UB-tree, to find objects that fit in areas that should be redrawn.

Similar Threads

  1. Configure Qt without examples?
    By Boron in forum Installation and Deployment
    Replies: 9
    Last Post: 8th September 2011, 19:24
  2. Examples on QTOPIA
    By vmd.esys in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 1st April 2008, 13:59
  3. QCanvas automatically lose its focus.
    By Cutey in forum Qt Programming
    Replies: 1
    Last Post: 19th January 2007, 12:29
  4. Unable to resize a QCanvas.
    By yellowmat in forum Newbie
    Replies: 2
    Last Post: 21st June 2006, 13:52
  5. Replies: 7
    Last Post: 20th March 2006, 21: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.