I have Created a MainWindow with and Need to print the MainWindow (including all children).
How do I do this?
Are there any examples available?
Thanks
I have Created a MainWindow with and Need to print the MainWindow (including all children).
How do I do this?
Are there any examples available?
Thanks
I have created the MainWindow with this code
then used the print method as a slotQt Code:
ui(new Ui::MainWindow) { // MainWindow Constructor ui->setupUi(this); loadFile(); }To copy to clipboard, switch view to plain text mode
then errorQt Code:
264 void MainWindow::Print() 265 { 266 NotImplemented(); 267 268 QPrinter printer; 269 printer.setOutputFileName("Attenuation_Calculator.pdf"); 271 MainWindow.render(&printer); 272 273 }To copy to clipboard, switch view to plain text mode
C2143: syntax error : missing ';' before '.'
why...when the auto fill allows me to select .render as a method of MainWindow?
Last edited by anda_skoa; 12th April 2015 at 08:36. Reason: missing [code] tags
Do you have a member variable of your MainWindow class named "MainWindow"? If not, do you know C++? If the answers are "No" and "Yes", then you can probably figure out why line 271 won't compile.why...when the auto fill allows me to select .render as a method of MainWindow?
And learn to use [code ] & [/code ] tags to wrap the code lines when you post source code. (With no spaces after the word "code" in the square brackets).
I am new to C++ and Qt....trying very hard to get up to speed.
but I do not understand what you mean d_stranz..
do you have a reference or example of what you mean ?
There is no object named "MainWindow" in scope where that statement is. There is, however, a type called "MainWindow" so the compiler is expecting an explicit call to method in the MainWindow class, like "MainWindow::staticFunc();", or a declaration, like "MainWindow foobar;", and does not find one before the dot and generates and error. You want neither of these anyway.
Assuming you are trying to print the window corresponding to the object this code is executing in then you should be calling render() on "this" object, i.e:
"We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.
ChrisW67,
When I use render(&printer);
this causes a LNK2019 error
Print method.jpg
as per the attachment.
does it make any difference that I am using a .ui file to create the mainwindow?
How do I overcome this problem ?
and allow the linking to the printersupport library?
And you make sure you run qmake to create an updated Makefile with the new library name.You add QT+=libraryname (e.g. printsupport) to your project file.
Bookmarks