Does somebody know how to make QChart look like on the image below?
I have created bar QBarChart and set its background color and color of the bar and removed axis numbers, but I don't know how to set title of the chart to look like this.
How to make the background of the title to have different color and to take same width as the QChart?
I did as Spinkoo suggested.
Created QLabel in MainWindow constructor and created function which is used to position QLabel over QChart. That function must be called after the constructor of the MainWindow, because then all of the sizes and positions of the widgets and layouts are known. That function is called after the constructor of the MainWindow and each time when Resize event happens.
void MainWindow::positionLabel()
{
// ui->widget inside which is QChart
// ui->verticalLayout inside which is ui->widget
QPoint pos = ui->widget->pos() + ui->verticalLayout->geometry().topLeft();
// m_title pointer to QLabel which is created inside constructor
m_title->setGeometry(pos.x() + 10, pos.y() + 20, ui->widget->width() - 20, CHART_TITLE_SIZE * 2.2);
this->repaint();
return;
}
This is pretty much a workaround solution, probably there should be a way to create custom QChart class which will have the look as the chart from the question. So, if someone knows how to do that, I'd appreciate sharing.