Quantcast
Viewing all articles
Browse latest Browse all 4972

Print multiple tabs to single pdf

Dear qt quick community! I am still learning qml and I am currently developing a tool for myself. Following you find a screenshot of what the tool roughly looks like at the moment: So basically, I have an application window with some tool buttons and multiple tabs. What I what to do now, is to implement the ‘saveAsPdf’-button, which gathers all the information on the different tabs and creates a pdf. My problem is that I am not able to access the data (e.g. comboboxes, textfields, listview etc.) from the ToolButton in the ApplicationWindow. Following you find my code so far: main.qml: import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Controls.Styles 1.1 import QtQuick.Layouts 1.1     import "MyConst.js" as Const   ApplicationWindow {       id: id_applicationWindow       width: 800     height: 800       property int margin: 11       Component{         id: id_comp         MyTab{             id: id_myTab         }     }       menuBar: MenuBar {         Menu {             title: "File"             MenuItem { text: "Open..." }             MenuItem { text: "Close" }         }         Menu {             title: "Edit"             MenuItem { text: "Cut" }             MenuItem { text: "Copy" }             MenuItem { text: "Paste" }         }     }       toolBar: ToolBar {           width: id_applicationWindow.width         height: 50           ToolButton {             id: id_addTab             text: "add tab"             anchors.verticalCenter: parent.verticalCenter             onClicked: {                 id_tabView.myAddTab("tab", id_comp)             }         }           ToolButton {             id: id_removeTab             text: "remove tab"             anchors.left: id_addTab.right             anchors.leftMargin: Const.mySpacing             anchors.verticalCenter: parent.verticalCenter             onClicked: {                 id_tabView.myRemoveCurrentTab();             }         }           ToolButton {             id: id_save             text: "saveAsPdf"             anchors.left: id_removeTab.right             anchors.leftMargin: Const.mySpacing             anchors.verticalCenter: parent.verticalCenter             onClicked: {                 console.log("number of open tabs: " + id_tabView.count)                 console.log("current tab: " + id_tabView.currentIndex)                 var nbTabs = id_tabView.count                 for (var i=0; i<nbTabs; i++) {                     console.log("airport tab " + i + ": " + id_tabView.getTab(i).children)                     console.log("nb children: " + id_tabView.getTab(i).children.length)                     var myChildrenList = id_tabView.getTab(i).children                 }             }         }     }       TabView{         id: id_tabView         anchors.fill: parent           Tab{             id: id_tab0             title: "myTab"             MyTab{                 id: id_myTab             }         }           function myAddTab(title, componentID){             if (id_tabView.count < 10)                 id_tabView.addTab(title, componentID)         }           function myRemoveCurrentTab(){             if (id_tabView.count > 1)                 id_tabView.removeTab(id_tabView.currentIndex)         }       }   } a snippet of MyTab.qml: import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Layouts 1.1   import QtQuick.XmlListModel 2.0 import QtQuick.Controls.Styles 1.1   import "MyFunctions.js" as FormatFunctions   import DownloadManager 1.0 import XMLCrawler 1.0   Item{     id: id_itemTab     anchors.fill: parent     anchors.margins: 8         ColumnLayout { ... } What is the best way to access all the data on the different tabs? Do you have any suggestions? I am very thankful for any hint or suggestion…also concerning my code in general! Thank you very much! PS: when I hit the button ‘remove tab’, I get the following typeError: “MyTab.qml:15: TypeError: Cannot read property of null” where line 15 is: “anchors.fill: parent” in MyTab.qml I wasn’t able to figure out why I get this error…any hints?

Viewing all articles
Browse latest Browse all 4972

Trending Articles