本文整理汇总了C++中QAxObject::dynamicCall方法的典型用法代码示例。如果您正苦于以下问题:C++ QAxObject::dynamicCall方法的具体用法?C++ QAxObject::dynamicCall怎么用?C++ QAxObject::dynamicCall使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAxObject
的用法示例。
在下文中一共展示了QAxObject::dynamicCall方法的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()");
}
示例2: 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
}
示例3: 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)");//退出
}
示例4: writeHeader
void TechnicalReport::writeHeader()
{
QAxObject *range = getRange(QString("A%1:B%1").arg(currentRow));
range->dynamicCall("Merge()");
range->dynamicCall("SetValue(const QVariant&)",
QObject::tr("Категория ") + query->value(1).value<QString>());
currentRow++;
}
示例5: writeSuperHeader
void TechnicalReport::writeSuperHeader()
{
QAxObject *range = getRange(QString("A%1:B%1").arg(currentRow));
range->dynamicCall("Merge()");
range->dynamicCall("SetValue(const QVariant&)",
QObject::tr("Технические результаты ") + query->value(0).value<QString>() + " " +
query->value(2).value<QDate>().toString("dd.MM.yyyy"));
currentRow++;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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
}
示例9: readDataToTable
/**
*@brief 从指定的xls文件中把数据导入到tableWidget中
*@param tableWidget : 执行要导入到的tablewidget指针
*@return 导入成功与否 true : 成功
* false: 失败
*/
bool ExcelEngine::readDataToTable(QTableWidget *tableWidget)
{
if ( NULL == tableWidget )
{
return false;
}
//先把table的内容清空
int tableColumn = tableWidget->columnCount();
tableWidget->clear();
for (int n=0; n<tableColumn; n++)
{
tableWidget->removeColumn(0);
}
int rowcnt = nStartRow + nRowCount;
int columncnt = nStartColumn + nColumnCount;
//获取excel中的第一行数据作为表头
QStringList headerList;
for (int n = nStartColumn; n<columncnt; n++ )
{
QAxObject * cell = pWorksheet->querySubObject("Cells(int,int)",nStartRow, n);
if ( cell )
{
headerList<<cell->dynamicCall("Value2()").toString();
}
}
//重新创建表头
tableWidget->setColumnCount(nColumnCount);
tableWidget->setHorizontalHeaderLabels(headerList);
//插入新数据
for (int i = nStartRow+1, r = 0; i < rowcnt; i++, r++ ) //行
{
tableWidget->insertRow(r); //插入新行
for (int j = nStartColumn, c = 0; j < columncnt; j++, c++ ) //列
{
QAxObject * cell = pWorksheet->querySubObject("Cells(int,int)", i, j );//获取单元格
//在r新行中添加子项数据
if ( cell )
{
tableWidget->setItem(r,c,new QTableWidgetItem(cell->dynamicCall("Value2()").toString()));
}
}
}
return true;
}
示例10: CoInitialize
unsigned int WINAPI TextSpeech::ThreadTextToSpeech(void *arg)
{
CoInitialize(NULL);
QAxObject voiceObj;
bool bSuccess = voiceObj.setControl("96749377-3391-11D2-9EE3-00C04F797396");
if(bSuccess)
{
voiceObj.dynamicCall("SetRate(int)",-3).toInt();
voiceObj.dynamicCall("Speak(QString,SpeechVoiceSpeakFlags)",((TextSpeech *)arg)->m_strToSpeak,0).toInt();
}
CoUninitialize();
((TextSpeech *)arg)->SpeakThreadComplete();
return 0;
}
示例11: writeRow
bool Excel::writeRow(int row, QVariantList &list)
{
try {
char sCell[18];
memset(sCell, 0, 18);
int col = list.count();
if (col <= 26)
sprintf(sCell, " %c", 'A' + col - 1);
else
sprintf(sCell, "%c%c", 'A' + col / 26 - 1, 'A' + col % 26 - 1);
QString cell = sCell;
columnName = columnName.toUpper() > cell.toUpper() ? columnName : cell;
cell = cell.trimmed() + QString::number(row);
QString srange = "Range(\"A" + QString::number(row) + "\",\"" + cell + "\")";
if (!excelSheet)
return false;
QAxObject *range = excelSheet->querySubObject(srange.toLocal8Bit());
if (!range)
return false;
range->dynamicCall("SetValue2(const QVariantList&)", QVariant(list));
delete range;
return true;
} catch (...) {
return false;
}
}
示例12: test2
void test2()
{
QAxObject* excel = new QAxObject( "Excel.Application", 0);
excel->setProperty("Visible", true);
excel->dynamicCall("Quit()");
delete excel;
}
示例13: CreateExcel
/**
* @brief Create Excel File
* @param file [QString] the name of the opened file
* @return 0:success -1:failed
*/
bool QEXCEL::CreateExcel(QString file)
{
QDir dTemp;
if(dTemp.exists(file))
{
qDebug()<<" QExcel::CreateExcel: exist file"<<file;
return false;
}
qDebug()<<" QExcel::CreateExcel: succes";
/**< create new excel sheet file.*/
QAxObject * workSheet = excel->querySubObject("WorkBooks");
workSheet->dynamicCall("Add");
/**< save Excel.*/
QAxObject * workExcel= excel->querySubObject("ActiveWorkBook");
excel->setProperty("DisplayAlerts", 0);
workExcel->dynamicCall("SaveAs (const QString&,int,const QString&,const QString&,bool,bool)",file,56,QString(""),QString(""),false,false);
excel->setProperty("DisplayAlerts", 1);
workExcel->dynamicCall("Close (Boolean)", false);
/**< exit Excel.*/
//excel->dynamicCall("Quit (void)");
return true;
}
示例14: clearCell
void QEXCEL::clearCell(int row, int column)
{
QString cell;
cell.append(QChar(column - 1 + 'A'));
cell.append(QString::number(row));
QAxObject *range = sheet->querySubObject("Range(const QString&)", cell);
range->dynamicCall("ClearContents()");
}
示例15: writeRec
void PulkaReport::writeRec(uint draw_number)
{
bool right = draw_number > 8;
draw_number = (draw_number - 1) % 8;
uint offset = (currentPage - 1) * pageHeight + firstRecOffset + draw_number * 4;
QAxObject *range = getRange((right ? QString("L%1:M%2") : QString("A%1:B%2")).arg(offset).arg(offset + 1));
range->dynamicCall("SetValue(const QVariant&)",
query->value(3).toString() + " " + query->value(4).toString() + " " + query->value(5).toString());
}