Like other posters, I can make no sense at all of how to precisely scale the size of axes in pixels. In my case, I need to do this to align the plot precisely with scales seismograms from another window. Below is a code snippet where I have attempted to set both minimum and maximum sizes of the axisRect. I added in the margins based on an earlier comment that, despite the documentation, the axisRect is not the inner rect, but includes margins. It doesn't work either with or without margins. And in both cases, when I query the width of the rect, I get a nonsensical small number like 29 or 55. Any ideas?
spectrogramPlot_ = new QCustomPlot(this); spectrogramPlot_->setInteractions(0); spectrogramPlot_->axisRect()->setupFullAxesBox(true); spectrogramPlot_->xAxis->setLabel("time"); spectrogramPlot_->yAxis->setLabel("freq"); QCPColorMap* colorMap = new QCPColorMap(spectrogramPlot_->xAxis, spectrogramPlot_->yAxis); axisRect = spectrogramPlot_->axisRect(0); axisRect->setMaximumSize(trace_->selectionRect().width() + axisRect->margins().left()+ axisRect->margins().right(), 256); axisRect->setMinimumSize(trace_->selectionRect().width() + axisRect->margins().left()+ axisRect->margins().right(), 256); std::cerr << trace_->selectionRect().width() << "\n"; std::cerr << spectrogramPlot_->axisRect(0)->width() << "\n"; ... spectrogramPlot_->replot(); spectrogramPlot_->update();