Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Transparent background: QChartView



  • I would like to create a QChartView with transparent background, I mean, no white default background.

    I tryed:

    legendView->setWindowFlags(Qt::FramelessWindowHint);
    legendView->setAttribute(Qt::WA_NoSystemBackground);
    legendView->setAttribute(Qt::WA_TranslucentBackground, true);
    legendView->setAttribute(Qt::WA_TransparentForMouseEvents);
    legendView->setWindowOpacity(0.5);
    

    and

    chart->setContentsMargins(0, 0, 0, 0);
    chart->setBackgroundRoundness(0);
    

    But I got always the same white background.
    4af6927d-c792-4bb3-9d79-32eb1a66072b-image.png

    How can I do this?



  • Hi,
    Try using QChart::setBackgroundVisible:

    chart->setBackgroundVisible(false);
    


  • Hi,
    Try using QChart::setBackgroundVisible:

    chart->setBackgroundVisible(false);
    


  • @SamurayH Thank you so much! I'm looking for this line for hours in the Qt documentation...


Log in to reply