Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Insert QchartView into a QGraphicsView.
Forum Updated to NodeBB v4.3 + New Features

Insert QchartView into a QGraphicsView.

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 958 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AuLoMa
    wrote on last edited by AuLoMa
    #1

    Hi,
    I created a QGraphicsView in QtDesigner, that I have called "chart" and promoted in QChartView :
    promotion.png

    I wanna give him a chart from my main function.. For that, I created a function in mainwindow:

    void MainWindow::addChart(QChart * chart){
        this->centralWidget()->findChild<QChartView>("chart").setRenderHint(QPainter::Antialiasing);
        this->centralWidget()->findChild<QChartView>("chart").setChart(chart);
    }
    

    I call this function correctly in the main: :

    MainWindow w;
    QChart *chart = new QChart();
    // ...
     w.addChart(chart);
    

    However, the IDE accept it but when I start the compilation, this code dosen't compile. It returns errors like : no matching function for call to ‘QChartView(QObject*) dans qobject.h
    or : could not convert ‘qt_qFindChild_helper(((const QObject*)this), (* & aName), QtCharts::QChartView::staticMetaObject, options)’ from ‘QObject*’ to ‘const QtCharts::QChartView&’

    Is it a promotion error of the QGraphicsView ? Or maybe I should do something in the .pro file ? Or is there a more simple method to do that ?

    Thank you for your help.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      If you added the view in Design mode and promoted it, it should be accessible via
      ui->chart.

      So no need to find it again with findChild

      1 Reply Last reply
      2
      • A Offline
        A Offline
        AuLoMa
        wrote on last edited by
        #3

        Thanks ! that was the solution

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved