No member named 'toList' in 'QList<double>
时间: 2023-12-26 12:06:29 浏览: 63
custom-list-model.zip_List<Custom> list_list qt_qt list_qt lis
Apologies for the confusion. You're right, there is no `toList()` function in `QList<double>`. To calculate the number of grid lines on the x-axis using Qwt, you can iterate over the tick values and count the number of ticks. Here's an updated example:
```cpp
#include <qwt_plot.h>
#include <qwt_scale_div.h>
// Create a QwtPlot object
QwtPlot plot;
// Draw the plot...
// Get the x-axis scale division
QwtScaleDiv xScaleDiv = plot.axisScaleDiv(QwtPlot::xBottom);
QVector<double> xTicks = xScaleDiv.ticks().toDoubleVector();
// Calculate the number of grid lines
int gridCount = xTicks.size() - 1;
// Print the number of grid lines on the x-axis
qDebug() << "Number of grid lines on the x-axis: " << gridCount;
```
In this updated code, we use `toDoubleVector()` to convert the `QwtScaleDiv::ticks()` to a `QVector<double>`. Then, we subtract 1 from the size of the vector to get the number of grid lines on the x-axis.
阅读全文