int main(int argc, char** argv) { QApplication app(argc, argv); QTabWidget tab; QStringList lst; tab.setWindowTitle("Tab Example"); lst << "Windows" << "Linux" << "Android" << "MacOSX"; foreach(QString str, lst) { tab.addTab(new QLabel(str, &tab), QPixmap(":/" + str + ".jpg"), str); }
int main(int argc,char **argv) { QApplication app(argc,argv); QLabel *label_first = new QLabel("first"); QLabel *label_second = new QLabel("second"); QTabWidget w; w.addTab(label_first,"first"); w.addTab(label_second,"second"); w.setWindowTitle("test for QTabWidget"); w.show(); return app.exec(); }
static int dynamicNormalizerGuiMain(int argc, char* argv[]) { uint32_t versionMajor, versionMinor, versionPatch; MDynamicAudioNormalizer::getVersionInfo(versionMajor, versionMinor, versionPatch); //initialize application QApplication app(argc, argv); app.setWindowIcon(QIcon(":/res/chart_curve.png")); app.setStyle(new QPlastiqueStyle()); //create basic tab widget QTabWidget window; window.setWindowTitle(QString("Dynamic Audio Normalizer - Log Viewer [%1]").arg(QString().sprintf("v%u.%02u-%u", versionMajor, versionMinor, versionPatch))); window.setMinimumSize(640, 480); window.show(); //get arguments const QStringList args = app.arguments(); //choose input file const QString logFileName = (args.size() < 2) ? QFileDialog::getOpenFileName(&window, "Open Log File", QString(), QString("Log File (*.log)")) : args.at(1); if(logFileName.isEmpty()) { return EXIT_FAILURE; } //check for existence if(!(QFileInfo(logFileName).exists() && QFileInfo(logFileName).isFile())) { QMessageBox::critical(&window, QString().sprintf("Dynamic Audio Normalizer"), QString("Error: The specified log file could not be found!")); return EXIT_FAILURE; } //open the input file QFile logFile(logFileName); if(!logFile.open(QIODevice::ReadOnly | QIODevice::Text)) { QMessageBox::critical(&window, QString().sprintf("Dynamic Audio Normalizer"), QString("Error: The selected log file could not opened for reading!")); return EXIT_FAILURE; } //wrap into text stream QTextStream textStream(&logFile); textStream.setCodec("UTF-8"); double minValue = DBL_MAX; double maxValue = 0.0; unsigned int channels = 0; //parse header if(!parseHeader(textStream, channels)) { QMessageBox::critical(&window, QString("Dynamic Audio Normalizer"), QString("Error: Failed to parse the header of the log file!\nProbably the file is of an unsupported type.")); return EXIT_FAILURE; } //allocate buffers LogFileData *data = new LogFileData[channels]; QCustomPlot *plot = new QCustomPlot[channels]; //load data parseData(textStream, channels, data, minValue, maxValue); logFile.close(); //check data if((data[0].original.size() < 1) || (data[0].minimal.size() < 1) || (data[0].smoothed.size() < 1)) { QMessageBox::critical(&window, QString("Dynamic Audio Normalizer"), QString("Error: Failed to load data. Log file countains no valid data!")); delete [] data; delete [] plot; return EXIT_FAILURE; } //determine length of data unsigned int length = UINT_MAX; for(unsigned int c = 0; c < channels; c++) { length = qMin(length, (unsigned int) data[c].original.count()); length = qMin(length, (unsigned int) data[c].minimal .count()); length = qMin(length, (unsigned int) data[c].smoothed.count()); } //create x-axis steps QVector<double> steps(length); for(unsigned int i = 0; i < length; i++) { steps[i] = double(i); } //now create the plots for(unsigned int c = 0; c < channels; c++) { //init the legend plot[c].legend->setVisible(true); plot[c].legend->setFont(QFont("Helvetica", 9)); //create graph and assign data to it: createGraph(&plot[c], steps, data[c].original, Qt::blue, Qt::SolidLine, 1); createGraph(&plot[c], steps, data[c].minimal, Qt::green, Qt::SolidLine, 1); createGraph(&plot[c], steps, data[c].smoothed, Qt::red, Qt::DashLine, 2); //set plot names plot[c].graph(0)->setName("Local Max. Gain"); plot[c].graph(1)->setName("Minimum Filtered"); plot[c].graph(2)->setName("Final Smoothed"); //set axes labels: plot[c].xAxis->setLabel("Frame #"); plot[c].yAxis->setLabel("Gain Factor"); makeAxisBold(plot[c].xAxis); makeAxisBold(plot[c].yAxis); //set axes ranges plot[c].xAxis->setRange(0.0, length); plot[c].yAxis->setRange(minValue - 0.25, maxValue + 0.25); plot[c].yAxis->setScaleType(QCPAxis::stLinear); plot[c].yAxis->setTickStep(1.0); plot[c].yAxis->setAutoTickStep(false); //add title plot[c].plotLayout()->insertRow(0); plot[c].plotLayout()->addElement(0, 0, new QCPPlotTitle(&plot[c], QString("%1 (Channel %2/%3)").arg(QFileInfo(logFile).fileName(), QString::number(c+1), QString::number(channels)))); //show the plot plot[c].replot(); window.addTab(&plot[c], QString().sprintf("Channel #%u", c + 1)); } //run application window.showMaximized(); app.exec(); //clean up delete [] data; delete [] plot; return EXIT_SUCCESS; }