Я хочу прочитать текстовый файл формы данных и добавить диаграмму чисел в tabWidget
(tab1), но при показе был открыт новый виджет, как я могу это исправить?
void mainWindow::readfile(){
QFile config(":/new/prefix1/3.txt");
config.open(QIODevice::ReadOnly);
if(config.isOpen()){
QTextStream stream(&config);
while (!stream.atEnd()){
line = stream.readLine().split('\t');
//qDebug()<<line;
bool allOk(true);
bool ok;
for (int x = 0; x <= line.count()-1 && allOk; x++) {
val.append(line.at(x).toInt(&ok));
allOk &= ok;
}
}
}
else
qDebug()<<"not opened";
ui->stackedWidget->setCurrentIndex(8);
on_ecg_destroyed();
}
void mainWindow::on_ecg_destroyed()
{
QLineSeries *series = new QLineSeries();
for(int y=0;y<288;y++)
series->append(y,val[y]);
QChart *chart = new QChart();
chart->legend()->hide();
chart->addSeries(series);
chart->createDefaultAxes();
chart->setTitle("line chart");
QChartView *chartView = new QChartView(chart);
chartView->setRenderHint(QPainter::Antialiasing);
setCentralWidget(chartView);
resize(400, 300);
show();
}
Я используюQStackWidget
для определения страниц, и на одной из них (страницах) я использую QTabWidget
с четырьмя вкладками и хочу создать график на вкладке 1. QTabWidget
расположен в QStackWidget
index 8, После прочтенияфайл, покажите диаграмму на стр. 8 в tab1
.