qt中的全屏绘图

qt中的全屏绘图,qt,plot,qcustomplot,Qt,Plot,Qcustomplot,我正在使用QCustom Plot在qt中生成图形,但是生成的图形对于我来说太小了,即使在我在design选项卡中最大化了小部件大小之后也是如此。有没有办法使图形/绘图全屏显示? 当我运行代码并最大化gui窗口时,绘图本身的大小保持不变 void Cpp_Fire::on_manual_fire_clicked() { // Code for graph // generate some data: QVector<double> x(variables.

我正在使用QCustom Plot在qt中生成图形,但是生成的图形对于我来说太小了,即使在我在design选项卡中最大化了小部件大小之后也是如此。有没有办法使图形/绘图全屏显示? 当我运行代码并最大化gui窗口时,绘图本身的大小保持不变

void Cpp_Fire::on_manual_fire_clicked()
{


    // Code for graph
    // generate some data:
    QVector<double> x(variables.nr_samples), y(variables.nr_samples);

    for (int i=0; i<variables.nr_samples; ++i)
    {
        x[i] = x_axis[i]; 
        y[i] = y_axis[i]; 
    }


    ui->customPlot->addGraph();
    ui->customPlot->graph(0)->setData(x, y);

    ui->customPlot->xAxis->setLabel("x");
    ui->customPlot->yAxis->setLabel("y");

    ui->customPlot->xAxis->setRange(x[0], x[variables.nr_samples-1]);
    ui->customPlot->yAxis->setRange(0, 65000);
    ui->customPlot->replot();
}
void Cpp\u Fire::on\u manual\u Fire\u clicked()
{
//图形编码
//生成一些数据:
QVector x(变量.nr_样本),y(变量.nr_样本);
对于(inti=0;icustomPlot->addGraph();
用户界面->自定义绘图->图形(0)->设置数据(x,y);
ui->customPlot->xAxis->setLabel(“x”);
ui->customPlot->yAxis->setLabel(“y”);
ui->customPlot->xAxis->setRange(x[0],x[variables.nr_samples-1]);
ui->customPlot->yAxis->setRange(06500);
ui->customPlot->replot();
}

全屏设置Qcustomplot窗口:

setGeometry(QApplication::desktop()->screenGeometry()); /* in your QMainWindow derivative constructor */
现在,图形必须自动缩放:

ui->customPlot->rescaleAxes(); /* after the graph data is filled */
如果这还不够,您可以添加缩放或拖动图形的功能,以获得您喜欢的视图:

ui->customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);

您尝试过使用setViewport()吗函数?它通常在导出图形时使用,但允许您调整图形的大小,使其超出小部件的大小。请详细说明您所做的操作。@Bosman。我该怎么做?@Tay,我使用qcustomplot创建了一个图形,当我最大化弹出窗口时,包含图形的小部件的大小保持不变,我希望将其最大化或至少放大。@duane您应该使用Qt布局。请参阅文档:。您可以在designer中简单地执行此操作:@duane最好提供一些
代码或图像…等来帮助其他人回答您的问题。似乎您没有像Nejat所说的那样使用布局来管理QCustomPlot类小部件。您需要将QCustomPlot类小部件添加到gui窗口的布局中。