qt中如何操作word文檔獲取當前行數從而進行一系列操作


qt中如何操作word文檔獲取當前行數從而進行一系列操作,以下參考:

//獲取當前所在頁數
int currentPageNumber()
{
QAxObject* activeWindow = m_wordDocuments->querySubObject("ActiveWindow");
QAxObject* pane = activeWindow->querySubObject("ActivePane");
QAxObject* pages = pane->querySubObject("Pages");
int pageNumber = pages->property("Count").toInt();
return pageNumber;
}

//獲取當前行數
int currentRow()
{
QAxObject* selection = m_wordWidget->querySubObject("Selection");
int row = selection->dynamicCall("Information(QVariant&)",10).toInt();
return row;
}

注意:如果出現換頁操作,獲取當前行數會在前一頁的基礎上記錄行數,有時候需要減掉前一頁的行數;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM