예제 #1
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    const int n = 3;

    QTableWidget *mainTable = new QTableWidget(n,n);
    QTableWidgetItem *widgetItem = 0;
    QStringList nameItems;

      nameItems << "First" << "Second" << "Third";
      mainTable->setHorizontalHeaderLabels(nameItems); //set headers on Horizontal
      mainTable->setVerticalHeaderLabels(nameItems);   //set headers on Vertical

      for(int i = 0;  i < n; ++i)
        {
          for(int j = 0; j < n; ++j)
            {
              widgetItem = new QTableWidgetItem(QString("%1,%2").arg(i).arg(j));
              mainTable->setItem(i,j,widgetItem);
            }
        }
    mainTable->setGeometry(430,340,400,180);
    mainTable->setWindowTitle("Main table");
    mainTable->show();

    return a.exec();
}
예제 #2
0
파일: main.cpp 프로젝트: xizho10/qt
int main(int argc,char* argv[])
{
    QApplication app(argc,argv);
    QTableWidget* table = new QTableWidget();
    table->setWindowTitle("Connect to Mysql Database Example");

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("192.168.11.3");
    db.setDatabaseName("menudb");
    db.setUserName("root");
    db.setPassword("test");
    if (!db.open())
    {
      QMessageBox::critical(0, QObject::tr("Database Error"),
                db.lastError().text());
    }

    QSqlQuery query("SELECT * FROM test");

    table->setColumnCount(query.record().count());
    table->setRowCount(query.size());

    int index=0;
    while (query.next())
    {
    table->setItem(index,0,new QTableWidgetItem(query.value(0).toString()));
    table->setItem(index,1,new QTableWidgetItem(query.value(1).toString()));
    index++;
    }

    table->show();
    return app.exec();
}
예제 #3
0
int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    QTableWidget tableWidget;
//    tableWidget.setAttribute(Qt::WA_StaticContents);
    tableWidget.viewport()->setAttribute(Qt::WA_StaticContents);
    tableWidget.setRowCount(15);
    tableWidget.setColumnCount(4);
    for (int row = 0; row  < 15; ++row)
    for (int col = 0; col  < 4; ++col)
//        tableWidget.setCellWidget(row, col, new StaticWidget());
       tableWidget.setCellWidget(row, col, new CellWidget());
    tableWidget.resize(400, 600);
    tableWidget.show();

    return app.exec();
}
예제 #4
0
int main( int argc, char* argv[] )
{
	QApplication app( argc, argv );
	QTableWidget* tv = new QTableWidget();
	tv->setRowCount( 1440 );
	tv->setColumnCount( 3 );
	tv->setShowGrid( false );

	QHeaderView* vh = tv->verticalHeader();
	vh->sectionResizeMode( QHeaderView::Fixed );
	vh->setDefaultSectionSize( 4 );

	QLabel* lbl = new QLabel( "abc" );
	tv->setCellWidget( 1, 1, lbl );

	tv->setSpan( 1, 1, 10, 1 );

	tv->show();
	app.exec();
}
void EmployeeListDialog::ShowEmployeeList( std::map<int, Employee*> &itsEmployees )
{
	QTableWidget *tableWidget = this->ui->tableWidgetEmployeeList;
	int count = 0;
	for ( std::map<int, Employee *>::reverse_iterator it = itsEmployees.rbegin();
		it != itsEmployees.rend();
		++it ) {
			Employee *e = it->second;
			QString strID;

			tableWidget->setItem(count,0,new QTableWidgetItem(QString::number(e->GetEmpId(), 10)));
			tableWidget->setItem(count,1,new QTableWidgetItem(e->GetName().c_str()));
			tableWidget->setItem(count,2,new QTableWidgetItem(e->GetAddress().c_str()));
			tableWidget->setItem(count,3,new QTableWidgetItem("null"));

			++count;
	}

	tableWidget->show();
}
예제 #6
0
void MainWindow::showTable()
{
    QTextCursor cursor = editor->textCursor();
    QTextTable *table = cursor.currentTable();

    if (!table)
        return;

    QTableWidget *tableWidget = new QTableWidget(table->rows(), table->columns());

//! [9]
    for (int row = 0; row < table->rows(); ++row) {
        for (int column = 0; column < table->columns(); ++column) {
            QTextTableCell tableCell = table->cellAt(row, column);
//! [9]
            QTextFrame::iterator it;
            QString text;
            for (it = tableCell.begin(); !(it.atEnd()); ++it) {
                QTextBlock childBlock = it.currentBlock();
                if (childBlock.isValid())
                    text += childBlock.text();
            }
            QTableWidgetItem *newItem = new QTableWidgetItem(text);
            tableWidget->setItem(row, column, newItem);
            /*
//! [10]
            processTableCell(tableCell);
//! [10]
            */
//! [11]
        }
//! [11] //! [12]
    }
//! [12]

    tableWidget->setWindowTitle(tr("Table Contents"));
    tableWidget->show();
}
예제 #7
0
void TSController::processDataParams(){
    //    qDebug()<<"TSController::processDataParams";
    qDebug()<<"this is result button !";
    QTableWidget *qtw = ui->resultsTable;
    qtw->setColumnCount(2);
    qtw->setRowCount(12);
    qtw->verticalHeader()->setVisible(false);
    qtw->setHorizontalHeaderLabels(QString(tr("Параметр;Значение")).split(";"));
    qtw->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
    /* tsanalitics* ga = new tsanalitics();
    tstempanalitic* gao = new tstempanalitic();
    tstempanalitic* gai = new tstempanalitic();*/
    float AvgExpirationSpeed=0, MaxExpirationSpeed=0, AvgExpirationTime=0, AvgInspirationTime=0,
            AvgRoundTime=0, AvgTempIn=0, AvgTempOut=0, AvgTempInMinusAvgTempOut=0,  BreathingVolume=0, MVL=0, MinuteVentilation=0;
    float InspirationFrequency=0;
    int *vo = curveBuffer->volume();
    int *ti = curveBuffer->tempIn();
    int *to = curveBuffer->tempOut();
    QVector<int> volume,temp_in,temp_out;
    for(int i=0;i<curveBuffer->getLenght();i++){
        volume.push_back(vo[i]);
        temp_in.push_back(ti[i]);
        temp_out.push_back(to[i]);
    }
    VolumeSolver* vs = new VolumeSolver(volume,temp_in,temp_out);

    AvgExpirationSpeed = vs->getAverageExpirationSpeed();
    qtw->setItem(1,0,getQTableWidgetItem(tr("Средняя скорость выдоха(л/с)")));
    qtw->setItem(1,1,getQTableWidgetItem(QString::number(fabs(curveBuffer->volToLtr((int)AvgExpirationSpeed)))));

    MaxExpirationSpeed = vs->getMaxExpirationSpeed();
    qtw->setItem(2,0,getQTableWidgetItem(tr("Максимальная скорость выдоха(л/с)")));
    qtw->setItem(2,1,getQTableWidgetItem(QString::number(fabs(curveBuffer->volToLtr((int)MaxExpirationSpeed)))));

    AvgExpirationTime = vs->getAverageExpirationTime();
    qtw->setItem(3,0,getQTableWidgetItem(tr("Среднее время выдоха(с)")));
    qtw->setItem(3,1,getQTableWidgetItem((QString::number((float)AvgExpirationTime))));

    AvgInspirationTime = vs->getAverageInspirationTime();
    qtw->setItem(4,0,getQTableWidgetItem(tr("Среднее время вдоха(с)")));
    qtw->setItem(4,1,getQTableWidgetItem((QString::number((float)AvgInspirationTime))));

    AvgRoundTime = vs->getAverageCycleTime();
    qtw->setItem(5,0,getQTableWidgetItem(tr("Средняя время цикла(с)")));
    qtw->setItem(5,1,getQTableWidgetItem((QString::number((float)AvgRoundTime))));

    InspirationFrequency = vs->getInspirationFrequancyInOneMinute();
    qtw->setItem(6,0,getQTableWidgetItem(tr("Частота дыхания(ед/мин)")));
    qtw->setItem(6,1,getQTableWidgetItem((QString::number(InspirationFrequency))));

    MinuteVentilation = vs->getMinuteVentilation();
    qtw->setItem(8,0,getQTableWidgetItem(tr("Минутная вентиляция легких(л)")));
    qtw->setItem(8,1,getQTableWidgetItem(QString::number(curveBuffer->volToLtr(MinuteVentilation))));

    BreathingVolume = vs->getAverageInspiratonVentilation();
    qtw->setItem(7,0,getQTableWidgetItem(tr("Дыхательный объем(л)")));
    qtw->setItem(7,1,getQTableWidgetItem(QString::number(fabs(curveBuffer->volToLtr((int)BreathingVolume)))));

    MVL = vs->getTotalVentilation();
    qtw->setItem(9,0,getQTableWidgetItem(tr("Суммарная вентиляция легких(л)")));
    qtw->setItem(9,1,getQTableWidgetItem(QString::number(fabs(curveBuffer->volToLtr((int)MVL)))));

    //ga->clear();

    AvgTempIn = vs->getAverageInspirationTempetature();
    qtw->setItem(10,0,getQTableWidgetItem(tr("Средняя температура вдоха( 'C)")));
    qtw->setItem(10,1,getQTableWidgetItem(QString::number(curveBuffer->tempInToDeg(AvgTempIn))));
    //gai->clear();

    AvgTempOut = vs->getAverageExpirationTempetature();
    qtw->setItem(11,0,getQTableWidgetItem(tr("Средняя температура выдоха( 'C)")));
    qtw->setItem(11,1,getQTableWidgetItem(QString::number(curveBuffer->tempOutToDeg(AvgTempOut))));

    AvgTempInMinusAvgTempOut = AvgTempOut-AvgTempIn;
    qtw->setItem(12,0,getQTableWidgetItem(tr("Средняя Твдоха-Средняя Твыдоха( 'C)")));
    qtw->setItem(12,1,getQTableWidgetItem(curveBuffer->tempOutToDeg(AvgTempOut)-curveBuffer->tempInToDeg(AvgTempIn)));

    qtw->removeRow(0);
    qtw->show();
    delete vs;
}
예제 #8
0
void TSController::processDataParams(){

    TSCurveBuffer *cb= new TSCurveBuffer;

    readerThread->readd();
    //TSUsb3000Reader *rdr= readerThread->getReader();
    //rdr->read();
    //rdr->initDevice(cb);
    /*rdr->read();*/
    qDebug()<<"this is result button !";
    QTableWidget *qtw = ui->resultsTable;
    qtw->setColumnCount(2);
    qtw->setRowCount(11);
    qtw->verticalHeader()->setVisible(false);
    qtw->setHorizontalHeaderLabels(QString(tr("Параметр;Значение")).split(";"));
    qtw->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
    tsanalitics* ga = new tsanalitics();
    tstempanalitic* gao = new tstempanalitic();
    tstempanalitic* gai = new tstempanalitic();
    int AvgExpirationSpeed=0, MaxExpirationSpeed=0, AvgExpirationTime=0, AvgInspirationTime=0,
            AvgRoundTime=0, AvgTempIn=0, AvgTempOut=0, AvgTempInMinusAvgTempOut=0,  BreathingVolume=0, MVL=0;
    float InspirationFrequency=0;
    int i=0;
    int *vo = curveBuffer->volume();
    for(i=0;i<curveBuffer->getLenght();i++){
        ga->append(vo[i]);
    }
    ga->approximate();

    int *ti = curveBuffer->tempIn();
    for(i=0;i<curveBuffer->getLenght();i++){
        gai->append(ti[i]);
    }
    gai->findExtremums();
    gai->deleteBadExtremums();

    int *to = curveBuffer->tempOut();
    for(i=0;i<curveBuffer->getLenght();i++){
        gao->append(to[i]);
    }
    gao->findExtremums();
    gao->deleteBadExtremums();

    AvgExpirationSpeed = ga->getAvgExpiratorySpeed();
    qtw->setItem(1,0,getQTableWidgetItem(tr("Средняя скорость выдоха(л/с)")));
    qtw->setItem(1,1,getQTableWidgetItem(QString::number(fabs(curveBuffer->volToLtr(AvgExpirationSpeed)))));

    MaxExpirationSpeed = ga->getMaxExpiratorySpeed();
    qtw->setItem(2,0,getQTableWidgetItem(tr("Максимальная скорость выдоха(л/с)")));
    qtw->setItem(2,1,getQTableWidgetItem(QString::number(fabs(curveBuffer->volToLtr(100*MaxExpirationSpeed)))));

    AvgExpirationTime = ga->getAvgExpiratoryTime();
    qtw->setItem(3,0,getQTableWidgetItem(tr("Среднее время выдоха(с)")));
    qtw->setItem(3,1,getQTableWidgetItem((QString::number((float)AvgExpirationTime/100))));

    AvgInspirationTime = ga->getAvgInspiratoryTime();
    qtw->setItem(4,0,getQTableWidgetItem(tr("Среднее время вдоха(с)")));
    qtw->setItem(4,1,getQTableWidgetItem((QString::number((float)AvgInspirationTime/100))));

    AvgRoundTime = AvgExpirationTime+AvgInspirationTime;
    qtw->setItem(5,0,getQTableWidgetItem(tr("Средняя время цикла(с)")));
    qtw->setItem(5,1,getQTableWidgetItem((QString::number((float)AvgRoundTime/100))));

    InspirationFrequency = ga->getFrequency();
    qtw->setItem(6,0,getQTableWidgetItem(tr("Частота дыхания(ед/мин)")));
    qtw->setItem(6,1,getQTableWidgetItem((QString::number(InspirationFrequency))));

    BreathingVolume = ga->getBreathingVolume();
    qtw->setItem(7,0,getQTableWidgetItem(tr("Дыхательный объем(л)")));
    qtw->setItem(7,1,getQTableWidgetItem(QString::number(fabs(curveBuffer->volToLtr(BreathingVolume)))));

    MVL = ga->getMVL();
    qtw->setItem(8,0,getQTableWidgetItem(tr("Максимальная вентиляция легких(л)")));
    qtw->setItem(8,1,getQTableWidgetItem(QString::number(fabs(curveBuffer->volToLtr(MVL)))));

    ga->clear();

    AvgTempIn = gai->getMinAvgs();
    qtw->setItem(9,0,getQTableWidgetItem(tr("Средняя температура вдоха( 'C)")));
    qtw->setItem(9,1,getQTableWidgetItem(QString::number(curveBuffer->tempInToDeg(AvgTempIn))));
    gai->clear();

    AvgTempOut = gao->getMaxAvgs();
    qtw->setItem(10,0,getQTableWidgetItem(tr("Средняя температура выдоха( 'C)")));
    qtw->setItem(10,1,getQTableWidgetItem(QString::number(curveBuffer->tempOutToDeg(AvgTempOut))));

    AvgTempInMinusAvgTempOut = AvgTempOut-AvgTempIn;
    qtw->setItem(11,0,getQTableWidgetItem(tr("Средняя Твдоха-Средняя Твыдоха( 'C)")));
    qtw->setItem(11,1,getQTableWidgetItem(curveBuffer->tempOutToDeg(AvgTempOut)-curveBuffer->tempInToDeg(AvgTempIn)));
    qtw->removeRow(0);

    qtw->show();
}
예제 #9
0
void CQMathMatrixWidget::slotDerivButtonPressed()
{
#ifdef _DERIV_TEST_
  std::cout << "Deriv" << std::endl;

  CModel* pModel = CCopasiRootContainer::getDatamodelList()->operator[](0).getModel();
  CEvaluationNode* tmpnode = pModel->prepareElasticity(&pModel->getReactions()[0],
                             &pModel->getMetabolites()[0], false);

  CEvaluationNode* tmpnode2 = pModel->prepareElasticity(&pModel->getReactions()[0],
                              &pModel->getMetabolites()[0], true);

  //create empty environment. Variable nodes should not occur in an expression
  std::vector<std::vector<std::string> > env;

  std::string tmpstring = tmpnode->buildMMLString(false, env);
  std::string tmpstring2 = tmpnode2->buildMMLString(false, env);

  mpMML->setBaseFontPointSize(qApp->font().pointSize());
  mpMML->setFontName(QtMmlWidget::NormalFont, qApp->font().family());

  mpMML->setContent(tmpstring.c_str());

  mpMML2->setBaseFontPointSize(qApp->font().pointSize());
  mpMML2->setFontName(QtMmlWidget::NormalFont, qApp->font().family());

  mpMML2->setContent(tmpstring2.c_str());

  QTableWidget * pTable = new QTableWidget(pModel->getReactions().size(), pModel->getMetabolites().size());
  pTable->show();

  int i, imax = pModel->getMetabolites().size();
  int j, jmax = pModel->getReactions().size();

  for (i = 0; i < imax; ++i)
    for (j = 0; j < jmax; ++j)
      {
        //CEvaluationNode* tmpnode = pModel->prepareElasticity(pModel->getReactions()[j],
        //                                                     pModel->getMetabolites()[i], false);

        CEvaluationNode* tmpnode2 = pModel->prepareElasticity(&pModel->getReactions()[j],
                                    &pModel->getMetabolites()[i], true);

        //evaluate
        CExpression * tmpExp = new CExpression("tmp expr", pModel);
        tmpExp->setRoot(tmpnode2);
        tmpExp->compile();
        std::cout << tmpExp->calcValue() << std::endl;

        //create empty environment. Variable nodes should not occur in an expression
        std::vector<std::vector<std::string> > env;

        //std::string tmpstring = tmpnode->buildMMLString(false, env);
        std::string tmpstring2 = tmpnode2->buildMMLString(false, env);

        QtMmlWidget* tmpmml = new QtMmlWidget();
        tmpmml->setBaseFontPointSize(qApp->font().pointSize() - 2);
        tmpmml->setFontName(QtMmlWidget::NormalFont, qApp->font().family());
        tmpmml->setContent(tmpstring2.c_str());
        pTable->setCellWidget(j, i, tmpmml);

        //tmpmml = new QtMmlWidget();
        //tmpmml->setBaseFontPointSize(qApp->font().pointSize()-2);
        //tmpmml->setFontName(QtMmlWidget::NormalFont, qApp->font().family());
        //tmpmml->setContent(tmpstring.c_str());
        //pTable->setCellWidget(i, 1, tmpmml);
      }

  pTable->resizeColumnsToContents();
  pTable->resizeRowsToContents();
#endif
}