Hello, thank you for QCustomplot. I am trying to show multiple graphs in one window using multiple QCPAxisRect and QCPLayoutGrid.
Unfortunately I get a read access violation when I am trying to insert for example 4 Axis rect in the first row and only one in the second.
bool TestPage::init_component() { m_customplot = new QCustomPlot(this); m_customplot->plotLayout()->clear(); m_exitButton = new QPushButton("Exit"); m_vboxlayout = new QVBoxLayout; QCPLayoutGrid *cpLayout = new QCPLayoutGrid; std::vector<QCPAxisRect*> axisRects; size_t row(0), col(0); for(size_t i = 0; i < 6; i++) { axisRects.push_back(new QCPAxisRect(m_customplot)); cpLayout->addElement(row, col, axisRects[i]); col++; if(col > 3) { row++; col = 0; } } m_customplot->plotLayout()->addElement(cpLayout); m_vboxlayout->addWidget(m_customplot); m_vboxlayout->addWidget(m_exitButton); setLayout(m_vboxlayout); return true; }
I also tried the following without success.
bool TestPage::init_component() { m_customplot = new QCustomPlot(this); m_customplot->plotLayout()->clear(); m_exitButton = new QPushButton("Exit"); m_vboxlayout = new QVBoxLayout; QCPLayoutGrid *cpLayout = new QCPLayoutGrid; cpLayout->setWrap(4); cpLayout->setFillOrder(QCPLayoutGrid::FillOrder::foColumnsFirst); std::vector<QCPAxisRect*> axisRects; size_t row(0), col(0); for(size_t i = 0; i < 6; i++) { axisRects.push_back(new QCPAxisRect(m_customplot)); cpLayout->addElement(axisRects[i]); } m_customplot->plotLayout()->addElement(cpLayout); m_vboxlayout->addWidget(m_customplot); m_vboxlayout->addWidget(m_exitButton); setLayout(m_vboxlayout); return true; }
This is the code i am using. It works for all values < 4 but after that the value has to be a multiple of 4 or it fails.
Is there a way to allow for rows of different column size in a QCPLayoutGrid ? Thank you in advance.