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.
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.
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,
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:
{ //some code };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
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
Here chemCanvas is the class where I do all the painting operations.Qt Code:
{ //some code to draw on QFrame using QPainter }; //"chemEdit.cpp" { scrollChemCanvas = new ScrollChemCanvas ( this, readonly, "scrolledCanvas" ); CHECK_PTR( scrollChemCanvas ); canvas = scrollChemCanvas->getCanvas(); setCentralWidget( scrollChemCanvas ); }; //"chemEdit.h" //declaration for canvas and scrollChemCanvas is as follows ChemCanvas* canvas; ScrollChemCanvas *scrollChemCanvas; class ScrollChemCanvas : public QScrollView { canvas = new ChemCanvas( viewport(), readonly ); };To copy to clipboard, switch view to plain text mode
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
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