Details
-
Bug
-
Resolution: Unresolved
-
P1: Critical
-
None
-
6.6.2
-
None
Description
#include <QApplication> #include <QAxObject> #include <QMetaProperty> #include <QDebug> void PrintObjectProperties(QObject* const object) { auto const metaObject = object->metaObject(); qDebug() << "Static properties of object" << object << ":"; for (int i = 0; i < metaObject->propertyCount(); ++i) { auto const property = metaObject->property(i); qDebug() << " " << property.name() << "=" << property.read(object); } qDebug() << "Dynamic properties of object" << object << ":"; auto const dynamicPropertyNames = object->dynamicPropertyNames(); for (auto const& dynamicPropertyName: dynamicPropertyNames) { qDebug() << " " << dynamicPropertyName << "=" << object->property(dynamicPropertyName); } } int main(int argc, char* argv[]) { QApplication app(argc, argv); auto excel = QAxObject("Excel.Application"); Q_ASSERT(!excel.isNull()); auto const set_visible_success = excel.setProperty("Visible", true); Q_ASSERT(set_visible_success); auto const workbooks = excel.querySubObject("Workbooks"); Q_ASSERT(workbooks); auto const workbook = workbooks->querySubObject("Add()"); Q_ASSERT(workbook); auto const sheets = workbook->querySubObject("Worksheets"); Q_ASSERT(sheets); auto const sheet = sheets->querySubObject("Item(int)", 1); Q_ASSERT(sheet); auto const pageSetup = sheet->querySubObject("PageSetup"); Q_ASSERT(pageSetup); // Property Orientation is QVariante(invalid) PrintObjectProperties(pageSetup); // Fail to set Property Orientation auto const set_orientation_success = pageSetup->setProperty("Orientation", 2); Q_ASSERT(set_orientation_success); }
Some of the PageSetup properties have QVariant(invalid) as a value. They cannot be written either.
Here is the Property Print Out of Qt 6.6.2:
Static properties of object QAxObject(0x2f2c20b3fa0) : objectName = QVariant(QString, "") classContext = QVariant(ulong, 21) control = QVariant(QString, "") AlignMarginsHeaderFooter = QVariant(bool, true) Application = QVariant(IDispatch*, 0x2f2bfd322a8) BlackAndWhite = QVariant(bool, false) BottomMargin = QVariant(double, 54) CenterFooter = QVariant(QString, "") CenterFooterPicture = QVariant(IDispatch*, 0x2f2c207a7b8) CenterHeader = QVariant(QString, "") CenterHeaderPicture = QVariant(IDispatch*, 0x2f2c207abb8) CenterHorizontally = QVariant(bool, false) CenterVertically = QVariant(bool, false) ChartSize = QVariant(Invalid) Creator = QVariant(Invalid) DifferentFirstPageHeaderFooter = QVariant(bool, false) Draft = QVariant(bool, false) EvenPage = QVariant(IDispatch*, 0x2f2c207a038) FirstPage = QVariant(IDispatch*, 0x2f2c20794b8) FirstPageNumber = QVariant(int, -4105) FitToPagesTall = QVariant(int, 1) FitToPagesWide = QVariant(int, 1) FooterMargin = QVariant(double, 21.6) HeaderMargin = QVariant(double, 21.6) LeftFooter = QVariant(QString, "") LeftFooterPicture = QVariant(IDispatch*, 0x2f2c2079f38) LeftHeader = QVariant(QString, "") LeftHeaderPicture = QVariant(IDispatch*, 0x2f2c207aa38) LeftMargin = QVariant(double, 50.4) OddAndEvenPagesHeaderFooter = QVariant(bool, false) Order = QVariant(Invalid) Orientation = QVariant(Invalid) Pages = QVariant(IDispatch*, 0x2f2c20796b8) PaperSize = QVariant(Invalid) Parent = QVariant(IDispatch*, 0x2f2c21d8458) PrintArea = QVariant(QString, "") PrintComments = QVariant(Invalid) PrintErrors = QVariant(Invalid) PrintGridlines = QVariant(bool, false) PrintHeadings = QVariant(bool, false) PrintNotes = QVariant(bool, false) PrintQuality = QVariant(QVariantList, QList(QVariant(double, 600), QVariant(double, 600))) PrintTitleColumns = QVariant(QString, "") PrintTitleRows = QVariant(QString, "") RightFooter = QVariant(QString, "") RightFooterPicture = QVariant(IDispatch*, 0x2f2c207b1b8) RightHeader = QVariant(QString, "") RightHeaderPicture = QVariant(IDispatch*, 0x2f2c207a138) RightMargin = QVariant(double, 50.4) ScaleWithDocHeaderFooter = QVariant(bool, true) TopMargin = QVariant(double, 54) Zoom = QVariant(int, 100) Dynamic properties of object QAxObject(0x2f2c20b3fa0) :
Qt 5.15 gives the correct expected values:
Static properties of object QAxObject(0x22cb5e10420) : objectName = QVariant(QString, "") AlignMarginsHeaderFooter = QVariant(bool, true) Application = QVariant(IDispatch*, ) BlackAndWhite = QVariant(bool, false) BottomMargin = QVariant(double, 56.6929) CenterFooter = QVariant(QString, "") CenterFooterPicture = QVariant(IDispatch*, ) CenterHeader = QVariant(QString, "") CenterHeaderPicture = QVariant(IDispatch*, ) CenterHorizontally = QVariant(bool, false) CenterVertically = QVariant(bool, false) ChartSize = QVariant(int, 0) Creator = QVariant(int, 1480803660) DifferentFirstPageHeaderFooter = QVariant(bool, false) Draft = QVariant(bool, false) EvenPage = QVariant(IDispatch*, ) FirstPage = QVariant(IDispatch*, ) FirstPageNumber = QVariant(int, -4105) FitToPagesTall = QVariant(int, 1) FitToPagesWide = QVariant(int, 1) FooterMargin = QVariant(double, 21.6) HeaderMargin = QVariant(double, 21.6) LeftFooter = QVariant(QString, "") LeftFooterPicture = QVariant(IDispatch*, ) LeftHeader = QVariant(QString, "") LeftHeaderPicture = QVariant(IDispatch*, ) LeftMargin = QVariant(double, 50.4) OddAndEvenPagesHeaderFooter = QVariant(bool, false) Order = QVariant(int, 1) Orientation = QVariant(int, 1) Pages = QVariant(IDispatch*, ) PaperSize = QVariant(int, 9) Parent = QVariant(IDispatch*, ) PrintArea = QVariant(QString, "") PrintComments = QVariant(int, -4142) PrintErrors = QVariant(int, 0) PrintGridlines = QVariant(bool, false) PrintHeadings = QVariant(bool, false) PrintNotes = QVariant(bool, false) PrintQuality = QVariant(QVariantList, (QVariant(double, 600), QVariant(double, 600))) PrintTitleColumns = QVariant(QString, "") PrintTitleRows = QVariant(QString, "") RightFooter = QVariant(QString, "") RightFooterPicture = QVariant(IDispatch*, ) RightHeader = QVariant(QString, "") RightHeaderPicture = QVariant(IDispatch*, ) RightMargin = QVariant(double, 50.4) ScaleWithDocHeaderFooter = QVariant(bool, true) TopMargin = QVariant(double, 56.6929) Zoom = QVariant(int, 100) control = QVariant(QString, "") Dynamic properties of object QAxObject(0x22cb5e10420) :