Results 1 to 11 of 11

Thread: Layered Application

  1. #1
    Join Date
    Mar 2008
    Posts
    68
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Layered Application

    Hi,
    I am developing an RealTime Application.
    This application is suppose to an area where i should be able to layers. where in one particular layer i should be able to draw, one layer where i should be able to show background images and many layers each having its own purpose. i should also have the option to enable and disable layers. on the whole i need to know how Qt supports this to the maximum? and which Qt class is the best for this kind of requirement. I am a newbie to Qt. Can anyone please help in finding this by stating the advantages and disadvantages for each class that supports this kind of layered approach.
    ---
    Thanks...

  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: Layered Application

    Take a look at QGraphicsView and family.

  3. #3
    Join Date
    Mar 2008
    Posts
    68
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Layered Application

    I have done 50% of the application with QPainter with support for one layer.
    Now can i continue using QPainter only but still add multiple layers to it?

  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: Layered Application

    Yes, but you have to do everything yourself if you don't want to use the available architecture meant for such a usecase.

  5. #5
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Layered Application

    Sure you can do something like

    Qt Code:
    1. void paintEvent(QPaintEvent*)
    2. {
    3. QPainter painter(this);
    4.  
    5. //draw background
    6. painter.drawPixmap(...);
    7. painter.drawPath(...)
    8. ...
    9.  
    10. if(layer1enabled)
    11. {
    12. painter.save();
    13. painter.translate(...);
    14. painter.setOpacity(0.5);
    15. drawRects(...)
    16. painter.restore();
    17. }
    18. if(layer2enabled)
    19. {
    20. painter.save();
    21. painter.translate(...);
    22. painter.drawText(...);
    23. painter.restore();
    24. ...
    25. }
    26. }
    To copy to clipboard, switch view to plain text mode 
    The solution won't be as elegant as using GV. You would have no help from the framework mapping click events and such, but it is definately possible.

    On the other hand, QGraphicsItem also uses QPainter to draw, so porting your current code shouldn't be such a big problem.

  6. #6
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Layered Application

    I agree with wysota....
    GraphcisView wud be better. You will need to implement a custom graphicsitem as a layer. Once u implement it, other things wud be easy like setting opacity, selecting a layer, or some fancy shape layer....

  7. #7
    Join Date
    Mar 2008
    Posts
    68
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Post Re: Layered Application

    Hi thanks a lot for the replies

    I am working on a project, wherein i need to do the following,
    1.Receive data pumped from the server at the maximum possible rate.
    2.Draw this data on the widget.The data drawn has to be retained for a certain period of time, after which its removed.
    3.These data are suppose to be show on different layers depending on their type, Also i should be able to select the objects that are shown in each layer and do certain operations on them.

    Currently i am drawing all these data on one widget, each time i get a new data using Qpainter.
    Also for layers i thought i will use multiple transparent widgets , is this ok ?

    I even studied Graphics View Framework and i feel i need to map these individual data as GraphicsItem on the Scene and display the View.
    But i am not very clear whether to add the new data to already existing scene or create a new scene , also how to delete these data after certain period.

    so can any of u suggest how this porting could be done. will it be easier to do the porting to graphic view from QPainter for my requirement?
    if any of u have any samples on graphics view please share them other than those in Qt Documentation!
    I am also supposed to display MAPS(dgn,tiff and dted files for which OPenGl will be a good option) as one layer., provide zoom, pan facillity.
    Is there any specific class, which helps me out in this?

    Looking forward to your response

  8. #8
    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: Layered Application

    Quote Originally Posted by csvivek View Post
    Also for layers i thought i will use multiple transparent widgets , is this ok ?
    Not really.

    But i am not very clear whether to add the new data to already existing scene or create a new scene , also how to delete these data after certain period.
    Use a single scene and add or remove items on demand. You remove them by deleting them or using scene API for removing items (guess how the method is called).

    so can any of u suggest how this porting could be done. will it be easier to do the porting to graphic view from QPainter for my requirement?
    I say port to GV.
    Last edited by wysota; 3rd April 2008 at 09:37.

  9. #9
    Join Date
    Mar 2008
    Posts
    68
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Layered Application

    How to go about adding the layers in GV?
    Also is Map(Dted,tiff and DGN) related activities simplified in GV?

    How to change the color of an Item added to the scene based on some condition? say after 2 ms i need to change the color of an object drawn at (0,0) to green.

  10. #10
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Layered Application

    Quote Originally Posted by csvivek View Post
    How to go about adding the layers in GV?
    Also is Map(Dted,tiff and DGN) related activities simplified in GV?

    How to change the color of an Item added to the scene based on some condition? say after 2 ms i need to change the color of an object drawn at (0,0) to green.
    IMO have a look on http://sourceforge.net/projects/sketchbook/ QT based ..
    it chance color or delete item quickly. Only port to QGraphicsView

  11. #11
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Layered Application

    How to change the color of an Item added to the scene based on some condition? say after 2 ms i need to change the color of an object drawn at (0,0) to green.
    You can have a color attribute in the graphicsItem. Based on this u color the item. Changing color is just a matter of changing the value of the variable. Simple..


    Also for ur needs GraphicsView wud be best. It provides zoom facility.
    Selecting and removing objects is also easy. When u click in a scene, u get a list of items on that point. From the list u can select and remove the desired item/layer.

Similar Threads

  1. Loading library from application
    By mourad in forum Installation and Deployment
    Replies: 0
    Last Post: 2nd April 2008, 16:10
  2. dll + application
    By fpujol in forum Qt Programming
    Replies: 11
    Last Post: 15th April 2007, 19:37
  3. Replies: 3
    Last Post: 8th December 2006, 19:51
  4. Replies: 3
    Last Post: 31st March 2006, 19:38

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.