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. How to replace QwtLegend::legendItems()
Forum Updated to NodeBB v4.3 + New Features

How to replace QwtLegend::legendItems()

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 470 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.
  • R Offline
    R Offline
    rock37
    wrote on last edited by
    #1

    Hey,
    i'm on updating from qwt5 to qwt6 and i have a line like:

    QList<QWidget *> items = plot->legend()->legendItems();
    

    which is giving me the error message "there is not legendItems() ind QwtAbstractLegend" so i found QwtLegend and changed the line to

    QList<QWidget *> items = qobject_cast<QwtLegend*>(plot->legend())->legendWidgets();
    

    but legendWidgets wants a QVariant parameter, what should i do from here and am i right with the legendWidgets() method call ?

    R 1 Reply Last reply
    0
    • R rock37

      Hey,
      i'm on updating from qwt5 to qwt6 and i have a line like:

      QList<QWidget *> items = plot->legend()->legendItems();
      

      which is giving me the error message "there is not legendItems() ind QwtAbstractLegend" so i found QwtLegend and changed the line to

      QList<QWidget *> items = qobject_cast<QwtLegend*>(plot->legend())->legendWidgets();
      

      but legendWidgets wants a QVariant parameter, what should i do from here and am i right with the legendWidgets() method call ?

      R Offline
      R Offline
      rock37
      wrote on last edited by rock37
      #2

      @rock37 the hole function looks like:

      // XYZ inherits QwtPlot
      XYZ * plot = my_plots.constData().at(i);
      
          if ( plot->legend() )
          {
            QList<QWidget *> items = qobject_cast<QwtLegend*>(plot->legend())->legendWidgets(?????);
            for ( int i = 0; i < items.count(); i++ )
            {
              QwtLegendItem * legend = qobject_cast<QwtLegendItem *>(items [i]);
              QwtText         text   = legend->text();
              QwtText         newText(text);
              newText.setPaintAttribute(QwtText::PaintUsingTextFont, false);
              legend->setText(newText);
            }
          }
          plot_renderer.render(
              plot, &painter, QRect(plot->x(), plot->y(), plot->width(), plot->height())
          );
      
      Axel SpoerlA 1 Reply Last reply
      0
      • R rock37

        @rock37 the hole function looks like:

        // XYZ inherits QwtPlot
        XYZ * plot = my_plots.constData().at(i);
        
            if ( plot->legend() )
            {
              QList<QWidget *> items = qobject_cast<QwtLegend*>(plot->legend())->legendWidgets(?????);
              for ( int i = 0; i < items.count(); i++ )
              {
                QwtLegendItem * legend = qobject_cast<QwtLegendItem *>(items [i]);
                QwtText         text   = legend->text();
                QwtText         newText(text);
                newText.setPaintAttribute(QwtText::PaintUsingTextFont, false);
                legend->setText(newText);
              }
            }
            plot_renderer.render(
                plot, &painter, QRect(plot->x(), plot->y(), plot->width(), plot->height())
            );
        
        Axel SpoerlA Offline
        Axel SpoerlA Offline
        Axel Spoerl
        Moderators
        wrote on last edited by
        #3

        @rock37
        This post relates to Qwt, which is based on Qt, but it is not Qt. The Qwt mailing list is the right point of contact, I think.

        Software Engineer
        The Qt Company, Oslo

        R 1 Reply Last reply
        1
        • Axel SpoerlA Axel Spoerl

          @rock37
          This post relates to Qwt, which is based on Qt, but it is not Qt. The Qwt mailing list is the right point of contact, I think.

          R Offline
          R Offline
          rock37
          wrote on last edited by
          #4

          @Axel-Spoerl i have subscriped to the mailing list but i can't find a way to create a new thread.

          R 1 Reply Last reply
          0
          • R rock37

            @Axel-Spoerl i have subscriped to the mailing list but i can't find a way to create a new thread.

            R Offline
            R Offline
            rock37
            wrote on last edited by
            #5

            @rock37 found the way, thanks for the advice

            1 Reply Last reply
            0
            • Axel SpoerlA Axel Spoerl has marked this topic as solved on

            • Login

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