c++ - Qwt Plot:如何减少图例项之间的间距
问题描述
我发现 Qwt 图的图例中的行间距非常大。我想在图例中放置更多项目,而无需滚动并且不增加图例的大小。
有没有办法减少或删除图例中项目之间的间距?
编辑:
这是我得到的
这就是我想要的
这是一个示例代码,显示了我如何将曲线添加到图例中,然后显示在图例中。它并没有完全重现上面的情节,但显示了原理:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QwtPlot* plot = new QwtPlot(this);
setCentralWidget(plot);
// Add curves
for(int i=0; i<15; i++){
QwtPlotCurve *curve = new QwtPlotCurve( "Curve " + QString::number(i) );
curve->attach( plot );
curve->setPen( Qt::blue, 2 );
curve->setLegendAttribute( QwtPlotCurve::LegendShowLine );
}
// Add legend
QwtLegend *legend = new QwtLegend();
legend->setDefaultItemMode(QwtLegendData::Clickable); // make items clickable
connect(legend, SIGNAL(clicked(const QVariant &, int)), this, SLOT(onLegendItemClicked(const QVariant &,int)) );
plot->insertLegend( legend, QwtPlot::LeftLegend );
}
如果我删除线
legend->setDefaultItemMode(QwtLegendData::Clickable);
图例项目之间的间距减小了一点(仍然没有我想要的那么小),但是当单击项目时不会发出 clicked(...) 信号。
知道如何在不失去可点击性的情况下减少间距吗?
解决方案
推荐阅读
- ruby-on-rails - 如何将变量从控制器传递到rails中的部分视图文件?
- python - 如何在 Pandas 数据框中将 ISO-8601 对象转换为 DateTime 格式?
- laravel - 未找到 Laravel Aws\Kinesis\KinesisClient
- c# - FileSystemWatcher() 的文件过滤器
- c# - MVVM WPF:根据所选项目从 DataGridComboBoxColumn 中删除元素
- forms - 当我单击输入登录表单时,应在 ionic 4 中提交
- python-3.x - 为什么在 Ubuntu 19.10 中安装 tensorflow-gpu 后 tensorflow 不工作?
- javascript - Material-table:是否可以默认打开detailsPanel?
- php - 试图获取非对象的属性“cover_image”(查看:C:\Users\BWB\Documents\Laravel\asperablogs\resources\views\blogs\blogs.blade.php)
- python - Pandas DataFrame 分组索引匹配列表 - 索引分别小于 list[i+1] 和大于 list[i]