当前位置: 首页>>代码示例>>C++>>正文


C++ QAxObject::querySubObject方法代码示例

本文整理汇总了C++中QAxObject::querySubObject方法的典型用法代码示例。如果您正苦于以下问题:C++ QAxObject::querySubObject方法的具体用法?C++ QAxObject::querySubObject怎么用?C++ QAxObject::querySubObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QAxObject的用法示例。


在下文中一共展示了QAxObject::querySubObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: writeBody

void SportsmenReport::writeBody(const char *headers[], uint length)
{
    sheet = openDocument();
    for(uint i = 0; i < length; ++i)
    {
        QAxObject *range = sheet->querySubObject("Range(const QString&)",
                                                 QString('A'+i) + QString::number(1));
        range->dynamicCall("SetValue(const QVariant&)", QObject::tr(headers[i]));
        range->querySubObject("Font")->setProperty("Bold", true);
        range->querySubObject("Borders")->setProperty("LineStyle", xlSingle);
    }
    int rowid = 2, fieldsCount = length;
    while(query->next())
    {
        fieldsCount = query->record().count();
        for(int i = 0; i < fieldsCount; ++i)
        {
            QAxObject *range = sheet->querySubObject("Range(const QString&)",
                                                     QString('A'+i) + QString::number(rowid));
            range->dynamicCall("SetValue(const QVariant&)", QVariant(query->value(i).value<QString>()));
        }
        rowid++;
    }
    QAxObject *exported = sheet->querySubObject("Range(const QString&)",
                            (QString("A2:") + (QString('A'+(fieldsCount-1)) + QString::number(rowid-1))));
    exported->querySubObject("Borders")->setProperty("LineStyle", xlSingle);

    QAxObject *font = exported->querySubObject("Font");
    font->setProperty("Name", QObject::tr("Arial"));
    font->setProperty("Size", 10);

    sheet->querySubObject("Columns")->dynamicCall("AutoFit()");
}
开发者ID:kravitz,项目名称:kfais,代码行数:33,代码来源:reports.cpp

示例2: writeFooter

void PulkaReport::writeFooter()
{
    uint offset = currentPage * pageHeight;
    QAxObject *l1 = getRange(QString("A%1").arg(offset));
    QAxObject *l2 = getRange(QString("H%1:J%1").arg(offset));

    l1->dynamicCall("SetValue(const QVariant&)", QObject::tr("Гл. судья"));
    l2->dynamicCall("Merge()");
    l2->dynamicCall("SetValue(const QVariant&)", QObject::tr("Секретарь"));
    l1->querySubObject("Borders(int)", xlEdgeBottom)->setProperty("LineStyle", xlSingle);
    l2->querySubObject("Borders(int)", xlEdgeBottom)->setProperty("LineStyle", xlSingle);
    l1->querySubObject("Font")->setProperty("Name", "Arial Cyr");
    l2->querySubObject("Font")->setProperty("Name", "Arial Cyr");
    l1->querySubObject("Font")->setProperty("Size", 11);
    l2->querySubObject("Font")->setProperty("Size", 11);

    uint fstMainRow = (currentPage - 1) * pageHeight + firstRecOffset,
         lstMainRow = offset - 3;

    QAxObject *grid = getRange(QString("C%1:K%2").arg(fstMainRow).arg(lstMainRow));
    grid->querySubObject("Borders")->setProperty("LineStyle", xlContinious);
    grid->querySubObject("Borders")->setProperty("Weight", xlHairline);

    QAxObject *lCol = getRange(QString("A%1:B%2").arg(fstMainRow).arg(lstMainRow)),
              *rCol = getRange(QString("L%1:M%2").arg(fstMainRow).arg(lstMainRow));
    lCol->querySubObject("Font")->setProperty("Name", "Arial Cyr");
    rCol->querySubObject("Font")->setProperty("Name", "Arial Cyr");
    lCol->querySubObject("Font")->setProperty("Size", 12);
    rCol->querySubObject("Font")->setProperty("Size", 12);

    currentPage++;
}
开发者ID:kravitz,项目名称:kfais,代码行数:32,代码来源:reports.cpp

示例3: printFile

void MyTable::printFile(const QString& fileName)
{
    qDebug() << "PrintFile" << fileName;
#ifdef EXCEL
    if (!excel->isNull()) {
        if (excel->Workbooks()->Open(fileName)) {
            Excel::_Worksheet sheet(excel->ActiveSheet());
            sheet.PrintOut(1, 1, 1);
            excel->Workbooks()->Close(); //ActiveWorkbook()->Close(false);
        }
    }
#else
    QAxObject* excel = new QAxObject("Excel.Application", 0);
    excel->dynamicCall("SetVisible(bool)", true);
    QAxObject* workbooks = excel->querySubObject("Workbooks");
    QAxObject* workbook = workbooks->querySubObject("Open(const QString&)", fileName);
    QAxObject* sheets = workbook->querySubObject("Worksheets");
    if (workbooks->dynamicCall("Count()").toInt()) {
        QAxObject* sheet = sheets->querySubObject("Item(int)", 1);
        sheet->dynamicCall("PrintOut(QVariant, QVariant, QVariant)", 1, 1, 1);
        workbook->dynamicCall("Close()");
    }
    excel->dynamicCall("Quit()");
    excel->deleteLater();
#endif
}
开发者ID:XRay3D,项目名称:ASPT_NONLINEARITY_TEST,代码行数:26,代码来源:mytable.cpp

示例4: generateSchedule

bool ItemsList::generateSchedule()
{
    if (!m_actualTable.isEmpty() && mainOrderActive )
    {
        setAnimationVisible(true);
        emit animationVisible(getAnimationVisible());

        if( setPath().isEmpty() ) {
            runMsg("Nie wybrano lokalizacji.");
            setAnimationVisible(false);
            emit animationVisible(getAnimationVisible());
            return false;
        }

        QAxObject* excel;
        QAxObject* wbooks;
        QAxObject* book;
        QFileInfo scheduleFile("schedule.xlsm");
        QVariant excelPath;
        QVariant destPath;

        excelPath = QVariant(scheduleFile.absoluteFilePath().replace("/", "\\\\"));

        excel = new QAxObject("Excel.Application", this);
        excel->setProperty("Visible", false);
        excel->setProperty("DisplayAlerts",0);

        wbooks = excel->querySubObject("Workbooks");
        book = wbooks->querySubObject("Open (const QString&)", excelPath);
        destPath = excel->dynamicCall("Run(QVariant)", QVariant("runMacro"));

        book->dynamicCall("Close()");
        excel->dynamicCall("Quit()");

        runMsg("Wygenerowano harmonogram",destPath.toString());
        delete book;
        delete wbooks;
        delete excel;

        setAnimationVisible(false);
        emit animationVisible(getAnimationVisible());

        csvFile->remove();
        tableDialog->model->clear();
        mainOrderActive = false;
        return true;
     }
     else if(m_actualTable.isEmpty() || !mainOrderActive )
     {
        runMsg("Zamówienie jest puste.");
        return false;
    }

    return false;

}
开发者ID:RStravinsky,项目名称:MedicalTables,代码行数:56,代码来源:itemslist.cpp

示例5: QAxObject

QAxObject *BaseReport::openDocument()
{
    excel = new QAxObject("Excel.Application", 0);
    excel->dynamicCall("SetVisible(bool)", true);
    QAxObject *workbooks = excel->querySubObject("Workbooks");
    QAxObject *workbook = workbooks->querySubObject("Add()");
    QAxObject *sheet = workbook->querySubObject("ActiveSheet");
    sheet->dynamicCall( "Select()" );
    return sheet;
}
开发者ID:kravitz,项目名称:kfais,代码行数:10,代码来源:reports.cpp

示例6: on_btnExport_clicked

void MainWindow::on_btnExport_clicked()
{
    QDir dir(QDir::currentPath());
    QDate date;
    QSettings config(dir.currentPath()+"//app.ini",QSettings::IniFormat);
    QString path = config.value("/SETTINGS/path").toString();

    QString fileName = QFileDialog::getSaveFileName(this,tr("保存文件"),path + "/" + date.currentDate().toString("yyyy-MM-dd")+ui->cbWareH->currentText()+".xls",tr("Microsoft Office 2003(*.xls)"));
    if(fileName.isEmpty()){
        QMessageBox::critical(0,tr("错误"),tr("要保存的文件名为空"));
        return;
    }
    QSqlQuery query;

    query.exec(QString("execute dbo.pr_report_jxc_item;1 @as_from = '%1', @as_to = '%2', @as_branch = '%3', @as_itemcls = '%'")
               .arg(date.currentDate().toString("yyyy-MM-dd"))
               .arg(date.currentDate().toString("yyyy-MM-dd"))
               .arg(ui->cbWareH->currentData().toString()));

    QAxObject *excel = new QAxObject("Excel.Application");

    if(!excel){
        QMessageBox::critical(0,tr("错误"),tr("找不到Excel组件!"));
        delete excel;
        return;
    }

    excel->dynamicCall("SetVisible(bool)",false);
    excel->setProperty("Visible", false);
    excel->setProperty("DisplayAlerts", false);

    QAxObject *workbooks = excel->querySubObject("WorkBooks");
    workbooks->dynamicCall("Add");
    QAxObject *workbook = excel->querySubObject("ActiveWorkBook");
    QAxObject *worksheets = workbook->querySubObject("Sheets");
    QAxObject *worksheet = worksheets->querySubObject("Item(int)",1);
    int row = 1;


    while(query.next()){
        setCellValue(worksheet,row,"A","'"+query.value("cItem_C").toString());
        setCellValue(worksheet,row,"B","'"+query.value("cItem_N").toString());
        setCellValue(worksheet,row,"C","0");
        setCellValue(worksheet,row,"D",query.value("nSettleQty"));
        row ++;
    };

    workbook->dynamicCall("SaveAs(const QString&)",QDir::toNativeSeparators(fileName));
    config.setValue("/SETTINGS/path",fileName.left(fileName.lastIndexOf("/")));
    QMessageBox::information(this,tr("操作成功"),tr("保存成功!"));
    workbook->dynamicCall("Close()");
    worksheet->clear();
    excel->dynamicCall("Quit()");
    delete excel;
}
开发者ID:Aug-G,项目名称:StudyCpp,代码行数:55,代码来源:mainwindow.cpp

示例7: getUsedRange

void QEXCEL::getUsedRange(int *topLeftRow, int *topLeftColumn, int *bottomRightRow, int *bottomRightColumn)
{
    QAxObject *usedRange = sheet->querySubObject("UsedRange");
    *topLeftRow = usedRange->property("Row").toInt();
    *topLeftColumn = usedRange->property("Column").toInt();

    QAxObject *rows = usedRange->querySubObject("Rows");
    *bottomRightRow = *topLeftRow + rows->property("Count").toInt() - 1;

    QAxObject *columns = usedRange->querySubObject("Columns");
    *bottomRightColumn = *topLeftColumn + columns->property("Count").toInt() - 1;
}
开发者ID:khalilluo,项目名称:excelsets,代码行数:12,代码来源:qexcel.cpp

示例8: showInWindowsShell

bool showInWindowsShell(const QString &filePath, bool deselect) {
   QFileInfo appFI(filePath);
   auto matchPath = appFI.dir().path().toLower();
   auto matchName = appFI.fileName().toLower();

   QAxObject shellApp("Shell.Application");

   QAxObject *windows = shellApp.querySubObject("Windows()");
   windows->disableMetaObject();
   auto count = windows->dynamicCall("Count()").toInt();
   qDebug() << count;
   for (int i = 0; i < count; ++i) {
      QAxObject *win = windows->querySubObject("Item(QVariant)", {i});
      win->disableMetaObject();

      auto program = win->dynamicCall("FullName()").toString();
      QFileInfo programFI(program);
      if (programFI.baseName().toLower() != "explorer") continue;
      auto url = win->dynamicCall("LocationURL()").toUrl();
      if (!url.isLocalFile()) continue;
      auto path = url.path().mid(1).toLower();
      if (path != matchPath) continue;

      QAxObject *doc = win->querySubObject("Document()");

      QAxObject *folder = doc->querySubObject("Folder()");
      folder->disableMetaObject();
      QAxObject *folderItems = folder->querySubObject("Items()");
      folderItems->disableMetaObject();

      QAxObject *ourEntry = {};
      int count = folderItems->dynamicCall("Count()").toInt();
      for (int j = 0; j < count; j++) {
         QAxObject *entry = folderItems->querySubObject("Item(QVariant)", j);
         entry->disableMetaObject();
         auto name = entry->dynamicCall("Name()").toString().toLower();
         if (name == matchName) ourEntry = entry;
      }
      if (ourEntry) {
         if (false)
            ourEntry->dynamicCall("InvokeVerb(QVariant)", QVariant());  // open etc.
         auto rc = doc->dynamicCall("SelectItem(QVariant, int)", ourEntry->asVariant(),
                                    SVSI_SELECT | (deselect ? SVSI_DESELECTOTHERS : 0));
         auto hwnd = win->dynamicCall("HWND()").toLongLong();
         BringWindowToTop(HWND(hwnd));
         return true;
      }
   }
   return false;
}
开发者ID:KubaO,项目名称:stackoverflown,代码行数:50,代码来源:showinshell_win.cpp

示例9: return

QAxObject * ExcelOnglet::recupererPremiereCelluleVidePremiereColonne()
{
   QAxObject * derniereCellulePleinePremiereColonne =
      recupererDerniereCelluleNonVidePremiereColonne();
   return (QAxObject *)
          derniereCellulePleinePremiereColonne->querySubObject( "Offset(int, int)", 1, 0 );
}
开发者ID:feydriva,项目名称:Depistage,代码行数:7,代码来源:ExcelOnglet.cpp

示例10: init_word

//AC.template.verifiedRecord
void  MainWidget::init_word()
{
    QAxWidget word("Word.Application");
    word.setProperty("Visible", false);//隐式的打开一个word应用程序

    QAxObject * documents = word.querySubObject("Documents"); //获取所有工作文档
    documents->dynamicCall("Add (void)");//创建一个word文档
    QAxObject * document = word.querySubObject("ActiveDocument"); //获取当前激活的文档
    QAxObject *selection = word.querySubObject("Selection"); //写入文件内容

    QDateTime time = QDateTime::currentDateTime();//获取系统现在的时间
    QString    str = time.toString("yyyy-MM-dd hh:mm:ss ddd"); //设置显示格式
    selection->dynamicCall("TypeText(const QString&)","hello"+str);

    //设置保存
    QVariant newFileName("e:/test.doc"); //存放位置和名称
    QVariant fileFormat(1); //文件格式
    QVariant LockComments(false);
    QVariant Password("");     //设置打开密码
    QVariant recent(true);
    QVariant writePassword("");
    QVariant ReadOnlyRecommended(false);

    document->querySubObject("SaveAs(const QVariant&, const QVariant&,const QVariant&, const QVariant&, const QVariant&, const QVariant&,const QVariant&)",    newFileName, fileFormat, LockComments, Password, recent, writePassword, ReadOnlyRecommended);
    document->dynamicCall("Close (boolean)", true);   //关闭文档
    word.dynamicCall("Quit (void)");//退出
}
开发者ID:jingzhesiye,项目名称:9-0-3,代码行数:28,代码来源:edit_form.cpp

示例11: getUsedRowsCount

int QEXCEL::getUsedRowsCount()
{
    QAxObject *usedRange = sheet->querySubObject("UsedRange");
    int topRow = usedRange->property("Row").toInt();
    QAxObject *rows = usedRange->querySubObject("Rows");
    int bottomRow = topRow + rows->property("Count").toInt() - 1;
    return bottomRow;
}
开发者ID:khalilluo,项目名称:excelsets,代码行数:8,代码来源:qexcel.cpp

示例12: CellValue

QString QExcel::CellValue(int sheetIdx, int x, int y){

    if( sheetIdx < 1 || x < 1 || y < 1)
        return NULL;

    QAxObject* sheet = _sheets->querySubObject( "Item( int )", sheetIdx );
    QAxObject* cell = sheet->querySubObject("Cells(int,int)", y, x);
    QString ret = cell->property("Value").toString();
    return ret;
}
开发者ID:shuheilocale,项目名称:sandbox,代码行数:10,代码来源:qexcel.cpp

示例13: setCellFontBold

void QEXCEL::setCellFontBold(int row, int column, bool isBold)
{
    QString cell;
    cell.append(QChar(column - 1 + 'A'));
    cell.append(QString::number(row));

    QAxObject *range = sheet->querySubObject("Range(const QString&)", cell);
    range = range->querySubObject("Font");
    range->setProperty("Bold", isBold);
}
开发者ID:khalilluo,项目名称:excelsets,代码行数:10,代码来源:qexcel.cpp

示例14: setCellFontSize

void QEXCEL::setCellFontSize(int row, int column, int size)
{
    QString cell;
    cell.append(QChar(column - 1 + 'A'));
    cell.append(QString::number(row));

    QAxObject *range = sheet->querySubObject("Range(const QString&)", cell);
    range = range->querySubObject("Font");
    range->setProperty("Size", size);
}
开发者ID:khalilluo,项目名称:excelsets,代码行数:10,代码来源:qexcel.cpp

示例15: on_RSMV_buildFrom_PsBtn_clicked

void MainWidget::on_RSMV_buildFrom_PsBtn_clicked()
{
    QString strPath=getTemplatePath();
    QFile   file(strPath);

   //qDebug()<<strPath;

    if (!file.exists())
    {
        show_MsBox(QString::fromUtf8("找不到报表模板路径"),3000);
    }

#if 1
    QAxWidget* temp_AxWidget = new QAxWidget("Word.Application");
    temp_AxWidget->setProperty("Visible", true);                       //新建一个word应用程序,并设置为可见

    QAxObject* documents = temp_AxWidget->querySubObject("Documents");  //获取所有的工作文档
    documents->dynamicCall("Open(QVariant)",strPath );                  //路径不对打开奔溃

    QAxObject *selection = temp_AxWidget->querySubObject("Selection");
    QAxObject *find = selection->querySubObject("Find");


    QList<QVariant> list2;                                               //*****Find Word http://technet.microsoft.com/zh-cn/library/ff193977
    list2.append("{cUserName}");                                         //find text
    list2.append(QVariant());//2
    list2.append(QVariant());//3
    list2.append(QVariant());//4
    list2.append(QVariant());//5
    list2.append(QVariant());//6
    list2.append(QVariant());//7
    list2.append(QVariant());//8
    list2.append(QVariant());//9
    list2.append(QString::fromUtf8("深圳市星龙科技"));                     //replace text
    list2.append(2);//replace all:2
    list2.append(QVariant());//12
    list2.append(QVariant());//13
    list2.append(QVariant());//14
    list2.append(QVariant());//15

    replaceDocTypeList replaceDocTypeList_Data;                            //装载搜索内容和替换内容的列表
    fillReplaceDocTypeList(ui->from_information_TbWidget,&replaceDocTypeList_Data);

    for (int i = 0; i < replaceDocTypeList_Data.count(); i++)
    {
        list2.replace(0, replaceDocTypeList_Data.at(i).searchStr);
        list2.replace(9, replaceDocTypeList_Data.at(i).replaceStr);
        find->dynamicCall("Execute (QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant& ,QVariant& ,QVariant& , QVariant&, QVariant&, QVariant&, QVariant&)", list2);
      //qDebug()<<replaceDocTypeList_Data.at(i).replaceStr;
    }
#endif
//  documents->dynamicCall("Save()");//保存
//  documents->dynamicCall("Close(boolean)", true);//关闭文本窗口
//  temp_AxWidget->dynamicCall("Quit(void)");//退出word
}
开发者ID:jingzhesiye,项目名称:9-0-3,代码行数:55,代码来源:edit_form.cpp


注:本文中的QAxObject::querySubObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。