Results 1 to 12 of 12

Thread: Header and Footer

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: Header and Footer

    Do you place widgets inside that QFrame? I'm sorry, I just have trouble to understand how is your application implemented and you're not giving any details. Guessing again - but I take it that you draw directly on the frame, so my answer would be not to use any widgets for the header but draw it directly on the frame. I admit, that I would use the QCanvas framework instead

  2. #2
    Join Date
    Sep 2006
    Posts
    339
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    15
    Thanked 21 Times in 16 Posts

    Default Re: Header and Footer

    Quote Originally Posted by wysota View Post
    Do you place widgets inside that QFrame? I'm sorry, I just have trouble to understand how is your application implemented and you're not giving any details. Guessing again - but I take it that you draw directly on the frame, so my answer would be not to use any widgets for the header but draw it directly on the frame. I admit, that I would use the QCanvas framework instead
    Sorry,
    Let me explain about my application
    I have a class similar to like this

    Qt Code:
    1. class chemCanvas : public QFrame
    2. {
    3. //some code to draw on QFrame using QPainter
    4. };
    5.  
    6. //"chemEdit.cpp"
    7. class chemEdit : public QMainWindow
    8. {
    9. scrollChemCanvas = new ScrollChemCanvas ( this, readonly, "scrolledCanvas" );
    10. CHECK_PTR( scrollChemCanvas );
    11. canvas = scrollChemCanvas->getCanvas();
    12. setCentralWidget( scrollChemCanvas );
    13. };
    14.  
    15. //"chemEdit.h"
    16. //declaration for canvas and scrollChemCanvas is as follows
    17. ChemCanvas* canvas;
    18. ScrollChemCanvas *scrollChemCanvas;
    19.  
    20. class ScrollChemCanvas : public QScrollView
    21. {
    22. canvas = new ChemCanvas( viewport(), readonly );
    23. };
    To copy to clipboard, switch view to plain text mode 
    Here chemCanvas is the class where I do all the painting operations.
    chemEdit is the QMainWindow class with all the menuItems, and other widgets
    ScrollChemCanvas is the QScrollView which creates Scrollable area

    Now I want to provide a Insert button in class chemEdit, which will have a popup menu Header and Footer

    Insert->Header and Footer

    then when I click on Header and Footer I should get a rectangular area which I think is QLineEdit (not sure), also there will be a widget with InsertAutoText, Insert PageNo, Insert Date, Insert Time etc buttons as shown in the zipped file attached.

    Now first thing first what is the widget(or most suitable thing might not be a widget) that I should use for rectangular area, how can I Preview the current page on chemCanvas( just like "Print Preview").

    What is the best possible way that I can use to create header and footer for my aplication?
    It should be user friendly

    Hope this helped you to understand!!!

    Thankx

  3. #3
    Join Date
    Dec 2006
    Location
    Kędzierzyn-Koźle
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: Header and Footer

    The best solution depends on the architecture of a document ... I have similar problem long time ago making printpreview and printing where should be a header and footer and data that have to be print may be more than one page. I used a list of "frames" where each frame can have child frames and so on. Each frame on list represent item you would like to draw on a page. Then printing algorithm was something like that:

    1. Set the iterator/pointer of items to be printed on the first element of the list.
    2. If we are on the beggining of the page than insert header here.
    3. Knowing size of page and footer .. print each consecutive item from the list that fits in the space between header and footer.
    4. Draw footer.

    Than do the same on each page starting from point 2. printng rest of the items from the list.


    This kind of solution will always give you psibility to print in any format A4,A3,A2.
    If you still have same place between last printed item and footer but not big enough to print whole thing you may print clipping it and contiunue on next page ... it simply depends how you would like to print it.

    Maybe it is not very nice solution for dynamic pages (where you have to edit thinks on page ... however I think it is still possible to do - probably there exsits better way to do it)

    This is solution if you use page based edtion ... like in text processor.
    If you use big plane for editing like vector drawing programs (inkscape/corel) than I do not recomend this solution.

    You may use also decorator pattern. Which may be more suitable for your current priting model - I strongly suggest to get familiar with this approach at first place.

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.