Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Qwt 6.1 legend duplication
QtWS25 Last Chance

Qwt 6.1 legend duplication

Scheduled Pinned Locked Moved 3rd Party Software
4 Posts 3 Posters 1.6k Views
  • 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
    alex2323
    wrote on last edited by
    #1

    my code:
    @
    void MainWindow::drawGraphCpuGeneralSlot(int cpu)
    {
    int graphTimeInt = ui->spinBox->value();
    double graphTimeDouble = (double) graphTimeInt;

    QwtLegend *legend = new QwtLegend();
    
    ui->graphCPU->setTitle(QString::fromUtf8("cpu"));
    ui->graphCPU->insertLegend(legend);
    ui->graphCPU->setFooter("seconds");
    ui->graphCPU->setAxisScale(QwtPlot::xBottom,0.0,graphTimeDouble);
    ui->graphCPU->setAxisTitle(QwtPlot::yLeft,QString::fromUtf8("%"));
    ui->graphCPU->setAxisScale(QwtPlot::yLeft,0.0,100.0);
    
    cpuLine = new QwtPlotCurve(QString(""));
    cpuLine->setPen(QPen(Qt::darkGreen, mainLineInGraph));
    cpuLine->setTitle("usage - " + QString::number(cpu));
    
    this->cpuArray[0] = cpu;
    
    cpuLine->setRawSamples(this->cpuArrayTime,this->cpuArray,myIterator);
    cpuLine->attach(ui->graphCPU);
    
    for(int i=myIterator;i!=0;i--) {
    this->cpuArray[i] = this->cpuArray[i-1];
    }
    

    }
    @

    it is slot funtion. Slot is working, but legend is duplicating:
    http://farm8.staticflickr.com/7380/11495605866_817e00069c.jpg

    what's my be wrong? Thank you.

    1 Reply Last reply
    0
    • U Offline
      U Offline
      uwer
      wrote on last edited by
      #2

      Guess the legend is o.k. but you are creating/attaching another curve with the same title by accident with each data update.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        alex2323
        wrote on last edited by
        #3

        [quote author="uwer" date="1387730153"]Guess the legend is o.k. but you are creating/attaching another curve with the same title by accident with each data update.[/quote]

        Yes, I divided this function to two functions: one for initializing and one for updating. Now it works file. Thank you :)

        1 Reply Last reply
        0
        • K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          @alex2323
          welcome to devnet

          I have added "code wrappings (please see forum help)":http://qt-project.org/wiki/ForumHelp#e3f82045ad0f480d3fb9e0ac2d58fb01 to your original post. Please use them next time you have a code section in your post.

          Vote the answer(s) that helped you to solve your issue(s)

          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