Dear all
I am trying to do create a combo with paper sizes on the system.
I try to do it with
QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes () const;
But I want able to get the list yes.
Dear all
I am trying to do create a combo with paper sizes on the system.
I try to do it with
QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes () const;
But I want able to get the list yes.
This should work:
Qt Code:
QStringList list; QList<int> valueList; for(int i=0;i<paperSizes.keyCount();i++){ list << key(i); valueList << value(i); } for(int i=0;i<list.count();++i){ box->addItem(list.at(i), valueList.at(i)); }To copy to clipboard, switch view to plain text mode
I have a error like
staticMetaObject is not a member of qprinter
Ouch... QPrinter is not a QObject... Well... this won't work then
can we use
supportedPaperSources ?
Have a look at QPrintDialog sources.
Edit: Sorry, QPageSetupDialog...
I was able to get the dimentions of the pages right now, but I still cant get the names, maybe this would be helpfull for someone
Qt Code:
QPrinterInfo pinfo; QList<QPrinter::PaperSize> paperSizes = pinfo.defaultPrinter().supportedPaperSizes(); QPrinter pppp; QSizeF sizef; QVariant height_variant; QVariant width_variant; int height; int width; for(int i=0;i<paperSizes.count();++i){ pppp.setPaperSize(paperSizes.at(i)); height_variant = height; width_variant = width; comboBox->addItem(height_variant.toString() + "x" + width_variant.toString()); }To copy to clipboard, switch view to plain text mode
This link might help you.
http://www.gamedev.net/community/for...opic_id=437852
That's not really an answer. Qt can do such things on its own but it requires the enum to be defined in a QObject which is not the case here. I suspect it would be possible to declare a dummy QObject and declare the paper size enum there but it doesn't seem like a good solution.
Yes.
Ok, but then you have to manually construct mapping from enum to strings so you can just insert those strings to the combo-box instead. The same amount of work. I think the solution the thread author is looking for is to do this automatically.Since QPrinter is not derived from QObject, I suggested the link regarding C++.
There is no reason for it to be a QObject.Is there any reason why QPrinter is not a part of QObject ?
Bookmarks