Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. International
  3. Italian
  4. Configurazione QChart QChartWiew
Qt 6.12 LTS is out! See what's new in the release blog

Configurazione QChart QChartWiew

Scheduled Pinned Locked Moved Unsolved Italian
1 Posts 1 Posters 635 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.
  • P Offline
    P Offline
    piolo
    wrote on last edited by
    #1

    Buongiorno,

    in un grafico di una linea vorrei configurare la dimensione dellolo spazio in cui vengono scritti i valori; vorrei evitare che quando i valori dell'asse y diventano troppo grandi tutto il gafico si sposti verso destra.
    Copio un pezzo di codice se può servire:

    PlotterChatWiew::PlotterChatWiew( QWidget *parent ) :
    QChartView( new QChart, parent ),
    series( new QLineSeries )
    {
    // personalizzazione chart background
    chart()->setBackgroundBrush( Qt::gray );

    // personalizzazione plot area background
    chart()->setPlotAreaBackgroundBrush( Qt::gray );
    chart()->setPlotAreaBackgroundVisible( true );
    
    // aggiunge una serie
    chart()->addSeries( series );
    
    // definizione caratteristiche QChartView
    setMinimumSize( 800, 600 );;
    setRenderHint( QPainter::Antialiasing );
    
    // definizione asse x per QChart
    QValueAxis *axisX = new QValueAxis;
    axisX->setRange( 0, 20 );
    axisX->setTickCount( 10 + 1 );                                             // numero di colonne
    axisX->setLabelFormat( "%.2f" );
    //axisX->setTitleText( "Samples" );
    
    chart()->addAxis( axisX, Qt::AlignBottom );
    series->attachAxis( axisX );
    
    // definizione asse y per QChart
    QValueAxis *axisY = new QValueAxis;
    axisY->setRange( -10, 10 );
    axisY->setTickCount( 10 + 1 );                                             // numero di righe
    axisY->setLabelFormat( "%.2f" );
    //axisY->setTitleText( "Audio level" );
    
    chart()->addAxis( axisY, Qt::AlignLeft );
    series->attachAxis( axisY );
    
    chart()->legend()->hide();                                                 // nasconde la legenda
    

    }

    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
    • Unsolved