Results 1 to 12 of 12

Thread: Header and Footer

Hybrid View

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

    Default Header and Footer

    Hi guys,
    I have a QWidget and I'm implementing a simple painting application. I'm almost able to draw a line, circle, square etc. I'm also able to print the contents on the widget.

    Now my problem is I need to provide header and footer information where the user can enter pageNo, Date, Time, Author etc( as in Microsoft Word). But I'm unable to proceed further as to how can I do that.

    Please help me and if possible with some sample programs.

    Thanking you in advance

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

    Default Re: Header and Footer

    I think you have to give more details - what exactly is your problem? A general answer without knowing details is to use QPainter::drawText() to draw headers and footers.

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

    Default Re: Header and Footer

    Quote Originally Posted by wysota View Post
    I think you have to give more details - what exactly is your problem? A general answer without knowing details is to use QPainter::drawText() to draw headers and footers.
    What I mean is I want to provide header and footer information in my painting application.
    Simialr to Microsoft word.

    Please check the below zipped file for more details. Here I have assumed the I have
    a Insert->Header and Footer menuItem in MenuBar. After I click Header and Footer I should get as shown in the zipped file...

    Thankx for your understanding
    Attached Files Attached Files

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

    Default Re: Header and Footer

    Ok, but what exactly is the problem? If you're using QGraphicsView then simply add another item for the header and interact with it... If you want more specific help, you have to give more details about your design.

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

    Default Re: Header and Footer

    Quote Originally Posted by wysota View Post
    Ok, but what exactly is the problem? If you're using QGraphicsView then simply add another item for the header and interact with it... If you want more specific help, you have to give more details about your design.
    Hi wysota,
    thankx for your reply,

    The problem is how do I initiate, what widget I should use, I'm using Qt3.3.5 on my system.

    I cannot find any QGraphicsView in QtAssistant as it is defined in Qt4.x.x....

    thankx

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

    Default Re: Header and Footer

    How do you implement the rest of your painting app? Do you use QCanvas?

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

    Default Re: Header and Footer

    Quote Originally Posted by wysota View Post
    How do you implement the rest of your painting app? Do you use QCanvas?
    In this class I do the drawing for my application which can extend pages. I'm maintaining matrix form for displaying the items on chemCanvas. I have also defined pageSetup for my application where user can specify different page settings eg. A4, A3, B4 etc. I'm able to print all the information present on chemCanvas to a printer using QPainter.

    Now my problem is I need to provide header and footer information before printing. I know the size of printing area( i.e sizeof current page on chemCanvas). How can I do that???

    Thankx,

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

    Default Re: Header and Footer

    Implement the header or footer as yet another canvas item. Alternatively you can draw directly on the canvas view using QPainter, but I think it'll be easier when you use a canvas item for that.

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

    Default Re: Header and Footer

    Quote Originally Posted by wysota View Post
    Implement the header or footer as yet another canvas item. Alternatively you can draw directly on the canvas view using QPainter, but I think it'll be easier when you use a canvas item for that.
    my class looks something like this
    Qt Code:
    1. class chemCanvas : public QFrame
    2. {
    3. //some code
    4. };
    To copy to clipboard, switch view to plain text mode 

    So, in this case how can I provide the header and footer area, top and bottom of the entire pages, Also what widget should I use in Qt3.3.5 to see the print preview for the added header and footer. In print preview the widget should be readonly(ie not modifyable).

    When I run Microsoft word's header and footer implementation, it includes a rectangle like area for entering information, once the header and footer option in the insert menuItem is clicked. In Qt3.3.5 what widget should I use to implement the same.

    I think you got what I mean
    If not please let me know

    thankx
    Thankx

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    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

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

    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

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.