コード例 #1
1
ファイル: mainwindow.cpp プロジェクト: vlabel/qaccordion
/**
* @brief ctor for main window
*
* @param parent
*/
MainWindow::MainWindow(QWidget *parent):
    QMainWindow(parent)
{	
	m_pCentral = new QFrame;
	setCentralWidget(m_pCentral);

	m_mainLayout = new QHBoxLayout;
	m_mainLayout->setContentsMargins(1,1,1,1);
	m_mainLayout->setSpacing(1);
	centralWidget()->setLayout(m_mainLayout);
	m_mainLayout->addWidget(&m_accordion);
	m_accordion.setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);

	QAccordionItem *item = new QAccordionItem("Item1");
	QTableWidget *table = new QTableWidget();
	QTableWidgetItem *table_item = new QTableWidgetItem("Test talbe item");
	table->setColumnCount(1);
	table->setRowCount(1);
	table->setItem(0,0,table_item);
	item->setWidget(table);

	m_accordion.addItem(item);		

	QAccordionItem *item2 = new QAccordionItem("Item2");
	QLineEdit *lineEdit = new QLineEdit();
	lineEdit->setText("Testing Text");
	item2->setWidget(lineEdit);
	m_accordion.addItem(item2);		
	createInnerAccordion();

}
コード例 #2
0
ファイル: HttpUserSetupDialog.cpp プロジェクト: dtbinh/dviz
HttpUserSetupDialog::HttpUserSetupDialog(QWidget *parent)
	: QDialog(parent)
	, ui(new Ui::HttpUserSetupDialog)
{
	ui->setupUi(this);
	
	QTableWidget * tableWidget = ui->httpUsers;
	QList<HttpUser*> users = HttpUserUtil::instance()->users();
	
	tableWidget->setRowCount(users.size());
	int row = 0;
	foreach(HttpUser *user, users)
	{
		tableWidget->setItem(row, 0, new QTableWidgetItem(user->user()));
		tableWidget->setItem(row, 1, new QTableWidgetItem(user->pass()));
		tableWidget->setItem(row, 2, new QTableWidgetItem(QString::number(user->level())));
		
		QComboBox *levelCombo = new QComboBox();
		
		levelCombo->addItems(QStringList() << "Guest" << "User" << "Admin");
		levelCombo->setCurrentIndex(user->level());
		
		tableWidget->setCellWidget(row, 2, levelCombo);
		 
		row ++;
	}
コード例 #3
0
ファイル: Table.cpp プロジェクト: fferri/v_repExtCustomUI
void Table::setRowCount(int count, bool suppressSignals)
{
    QTableWidget *tablewidget = static_cast<QTableWidget*>(getQWidget());
    bool oldSignalsState = tablewidget->blockSignals(suppressSignals);
    tablewidget->setRowCount(count);
    tablewidget->blockSignals(oldSignalsState);
}
コード例 #4
0
ファイル: main.cpp プロジェクト: paulotovo/Examples
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QMainWindow *w = new QMainWindow();

    QTableWidget* table = new QTableWidget();
    table->setFixedSize(300,300);

    QPalette* palette = new QPalette();
    palette->setColor(QPalette::Highlight,Qt::cyan);
    table->setPalette(*palette);

    table->setRowCount(2);
    table->setColumnCount(3);
    table->setSelectionBehavior(QAbstractItemView::SelectRows);

    //Set Header Label Texts Here
    table->setHorizontalHeaderLabels(QString("HEADER 1;HEADER 2;HEADER 3").split(";"));

    //Add Table items here
    table->setItem(0,0,new QTableWidgetItem("ITEM 1_1"));
    table->setItem(0,1,new QTableWidgetItem("ITEM 1_2"));
    table->setItem(0,2,new QTableWidgetItem("ITEM 1_3"));

    table->setItem(1,0,new QTableWidgetItem("ITEM 2_1"));
    table->setItem(1,1,new QTableWidgetItem("ITEM 2_2"));
    table->setItem(1,2,new QTableWidgetItem("ITEM 2_3"));

    w->setCentralWidget(table);

    w->show();

    return a.exec();
}
コード例 #5
0
ファイル: tableview.cpp プロジェクト: kulikovv/ProcessingSDK
void TableView::addRow(types::Data &data, int fid)
{
    QTableWidget* table =  getTableWidget();

    if(0!=table)
    {
        if(fid>=table->rowCount())
        {
            table->setRowCount(fid+50);
        }
        unsigned int size = data.size();
        if(table->columnCount()<(int)size)
        {
            size = table->columnCount();
        }
        for(unsigned int i=0;i<size;i++)
        {
            table->setItem(fid,i,new QTableWidgetItem(QString("%1").arg(data[i])));
        }
        table->selectRow(fid);
        if(_realcount<fid)
        {
            _realcount = fid;
        }
   }
}
コード例 #6
0
ファイル: main.cpp プロジェクト: paulotovo/Examples
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QMainWindow *w = new QMainWindow();

    w->setWindowTitle(QString::fromUtf8("QTableWidget Merge Cells Example"));
    w->resize(400, 250);

    QTableWidget* table = new QTableWidget();

    //Set table row count 1 and column count 3
    table->setRowCount(1);
    table->setColumnCount(3);
    table->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);

    //Set Header Label Texts Here
    table->setHorizontalHeaderLabels(QString("HEADER 1;HEADER 2;HEADER 3").split(";"));

    QTableWidgetItem* item = new QTableWidgetItem("ITEM 2");
    item->setTextAlignment(Qt::AlignCenter);

    //Add Table items here
    table->setItem(0,0,new QTableWidgetItem("ITEM 1"));
    table->setItem(0,1,item);
    table->setSpan(0,1,1,2);

    w->setCentralWidget(table);

    w->show();

    return a.exec();
}
コード例 #7
0
ファイル: mainwindow.cpp プロジェクト: ryachart/Ballgame
void MainWindow::updateLevelPlistTable()
{
    noEmit = true;

    QTableWidget *table = ui->levelPlistTableWidget;

    int count = levelPlist.count();
    table->setRowCount(count);
    table->setColumnCount(2);

    QMap<QString, QVariant>::const_iterator i;
    int index = 0;

    for (i = levelPlist.constBegin(); i != levelPlist.constEnd(); ++i)
    {
        table->setItem(index, 0, new QTableWidgetItem(i.key()));

        if(i.value().type() == QVariant::String)
        {
            table->setItem(index, 1, new QTableWidgetItem(i.value().toString()));
        }
        else if(i.value().type() == QVariant::List)
        {
            table->setItem(index, 1, new QTableWidgetItem(QString("Click to edit")));
        }
        else
        {
            Q_ASSERT_X(false, "MainWindow::updateObjectTable", "Unknown QVariant type!");
        }
        index++;
    }

    noEmit = false;
}
コード例 #8
0
ファイル: rcmanagerdlg.cpp プロジェクト: johngtx/wrcpackage
void RcManagerDlg::updateFileInfoTable()
{
    QTableWidget* tb = ui->tb_file_list;
    QStringList header;
    const QVector<FILEINFO>& fileInfos = m_parse.getFileInfoList();
    header << "Index" << "Name" << "Offset" << "Length" << "Type";
    tb->clear();
    tb->setRowCount(fileInfos.count());
    tb->setColumnCount(5);
    tb->setHorizontalHeaderLabels(header);
    ui->tb_file_list->setHorizontalHeaderLabels(header);

    int row = 0;
    foreach(const FILEINFO& info, fileInfos)
    {
        QTableWidgetItem* indexItem = new QTableWidgetItem(QString("%1").arg(info.index));
        if(!indexItem)
        {
            continue;
        }

        indexItem->setData(WRCINDEXROLE, info.index);
        tb->setItem(row, INDEX, indexItem);
        tb->setItem(row, NAME, new QTableWidgetItem(QString(info.name)));
        tb->setItem(row, OFFSET, new QTableWidgetItem(QString("%1").arg(info.offset)));
        tb->setItem(row, LENGTH, new QTableWidgetItem(QString("%1").arg(info.length)));
        tb->setItem(row, TYPE, new QTableWidgetItem(QString("%1").arg(info.type)));
        row++;
    }
コード例 #9
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();
}
コード例 #10
0
void PageMemoryRights::RunAddrSize(duint addrin, duint sizein, QString pagetypein)
{
    addr = addrin;
    size = sizein;
    pagetype = pagetypein;

    QTableWidget* tableWidget = ui->pagetableWidget;
    tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
    duint nr_pages = size / PAGE_SIZE;
    tableWidget->setColumnCount(2);
    tableWidget->setRowCount(nr_pages);
    tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(QString(tr("Address"))));
    tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem(QString(tr("Rights"))));

    duint actual_addr;
    char rights[RIGHTS_STRING_SIZE];
    for(duint i = 0; i < nr_pages; i++)
    {
        actual_addr = addr + (i * PAGE_SIZE);
        tableWidget->setItem(i, 0, new QTableWidgetItem(ToPtrString(actual_addr)));
        if(DbgFunctions()->GetPageRights(actual_addr, rights))
            tableWidget->setItem(i, 1, new QTableWidgetItem(QString(rights)));
    }

    QModelIndex idx = (ui->pagetableWidget->model()->index(0, 0));
    ui->pagetableWidget->selectionModel()->select(idx, QItemSelectionModel::Select);
    idx = (ui->pagetableWidget->model()->index(0, 1));
    ui->pagetableWidget->selectionModel()->select(idx, QItemSelectionModel::Select);

    ui->radioFullaccess->setChecked(true);
    ui->chkPageguard->setCheckable(true);
    exec();
}
コード例 #11
0
ファイル: tableview.cpp プロジェクト: kulikovv/ProcessingSDK
void TableView::receiveProcess(esp data)
{


    QSharedPointer<types::pData> full = data.getReadOnly<types::pData>();
    if(!full.isNull())
    {
		//INFO("Recieve full")
        setHeader(full->header());
        QTableWidget* table =  getTableWidget();
        if(0!=table)
        {
            table->setRowCount(0);
        }
        for(uint i=0;i<full->size();i++)
        {
            types::Data d = (*full)[i];
            if(!d.isempty()){
                addRow(d,d.frameId());
            }
        }
    }
    QSharedPointer<types::Data> item = data.getReadOnly<types::Data>();
    if(!item.isNull())
    {
        if(item->header()!=_header)
        {
            setHeader(item->header());
        }
        addRow(*item,data.getFrameId());
    }
}
コード例 #12
0
ActivateModsDialog::ActivateModsDialog(const std::map<QString, std::vector<QString> > &missingPlugins, QWidget *parent)
  : TutorableDialog("ActivateMods", parent), ui(new Ui::ActivateModsDialog)
{
  ui->setupUi(this);

  QTableWidget *modsTable = findChild<QTableWidget*>("modsTable");
  QHeaderView *headerView = modsTable->horizontalHeader();
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
  headerView->setSectionResizeMode(0, QHeaderView::Stretch);
  headerView->setSectionResizeMode(1, QHeaderView::Interactive);
#else
  headerView->setResizeMode(0, QHeaderView::Stretch);
  headerView->setResizeMode(1, QHeaderView::Interactive);
#endif

  int row = 0;

  modsTable->setRowCount(missingPlugins.size());

  for (std::map<QString, std::vector<QString> >::const_iterator espIter = missingPlugins.begin();
       espIter != missingPlugins.end(); ++espIter, ++row) {
    modsTable->setCellWidget(row, 0, new QLabel(espIter->first));
    if (espIter->second.size() == 0) {
      modsTable->setCellWidget(row, 1, new QLabel(tr("not found")));
    } else {
      QComboBox* combo = new QComboBox();
      for (std::vector<QString>::const_iterator modIter = espIter->second.begin();
           modIter != espIter->second.end(); ++modIter) {
        combo->addItem(*modIter);
      }
      modsTable->setCellWidget(row, 1, combo);
    }
  }
}
コード例 #13
0
// get speaker's themes by language
QTableWidget *PublicTalks::getSpeakerPublicTalks(int kieli_id, int personid, QString select) {
    QTableWidget *table = new QTableWidget(0,3);
    table->verticalHeader()->setVisible(false);

    //sitten vectoriin kaikki aiheet
    std::vector<sql_item> q;
//    q = sql.selectSql("SELECT * FROM Esitelmat, P_esitelmat WHERE Esitelmat.kieli_id = '"+ kielet[0].getValue("id") +"'"
//                      " AND Esitelmat.aihe_id = P_esitelmat.aihe_id"
//                      " AND P_esitelmat.puhuja_id = '" + QString::number(personid) + "'");
    q = sql.selectSql("SELECT Esitelmat.*, P_esitelmat.puhuja_id, yleisokokous.pvm FROM Esitelmat "
                      "LEFT JOIN yleisokokous ON Esitelmat.aihe_id = yleisokokous.aihe_id "
                      "LEFT JOIN P_esitelmat ON Esitelmat.aihe_id = P_esitelmat.aihe_id "
                      "WHERE P_esitelmat.puhuja_id = '" + QString::number(personid) + "' "
                      "AND Esitelmat.kieli_id = '"+ langId +"' "
                      "GROUP BY Esitelmat.aihe_id ORDER BY Esitelmat.aihe_id");
    table->setRowCount(q.size()+1);
    for(unsigned int i = 0; i < q.size(); i++) {

        int value = QVariant(q[i].getValue("aihe_id")).toInt();
        QTableWidgetItem *item = new QTableWidgetItem();
        item->setData(Qt::DisplayRole,value);
        table->setItem(i+1,0,item);
        //table->setItem(i+1,0,new QTableWidgetItem(q[i].getValue("aihe_id")));
        table->setItem(i+1,1,new QTableWidgetItem(q[i].getValue("aihe")));
        if(table->item(i+1,1)->text() == select) {
            QFont boldfont(table->item(i+1,1)->font().family(),
                           table->item(i+1,1)->font().pointSize(),
                           QFont::Bold);
            table->item(i+1,1)->setFont(boldfont);
        }
        table->setItem(i+1,2,new QTableWidgetItem(q[i].getValue("pvm")));
    }

    return table;
}
コード例 #14
0
ファイル: mainwindow.cpp プロジェクト: ryachart/Ballgame
void MainWindow::clearObjectTable()
{
    QTableWidget *table = ui->objectsTableWidget;
    table->clear();
    table->setRowCount(0);
    table->setColumnCount(0);
}
コード例 #15
0
void GraphPlotDialog::setGraphVisibility(int currentVisibility)
{
    QTableWidget *currentList = NULL;
    QTableWidget *endList = NULL;
    if (currentVisibility == 1) {
        currentList = mUi.visibleGraph;
        endList = mUi.invisibleGraph;
    }
    else if (currentVisibility == 0) {
        currentList = mUi.invisibleGraph;
        endList = mUi.visibleGraph;
    }
    else {
        return;
    }
    QTableWidgetItem *item = currentList->takeItem(currentList->currentRow(), 0);
    QTableWidgetItem *valueItem = currentList->takeItem(currentList->currentRow(), 1);

    if (!item || !valueItem) {
        return;
    }
    currentList->removeRow(currentList->currentRow());
    unsigned graphId = item->data(Qt::UserRole).toUInt();
    mData[graphId].isSelected = false;
    int rowCount = endList->rowCount();
    endList->setRowCount(rowCount + 1);
    endList->setItem(rowCount, 0, item);
    endList->setItem(rowCount, 1, valueItem);
}
コード例 #16
0
QTableWidget* StatusViewer::prepareTable(int rows, int cols) {
    QTableWidget* table = new QTableWidget(this);
    table->setColumnCount(cols);
    table->setRowCount(rows);
    table->setSelectionBehavior(QAbstractItemView::SelectRows);
    table->setAttribute(Qt::WA_MacShowFocusRect, 0);
    table->setShowGrid(false);
    table->setAlternatingRowColors(true);
    table->setSortingEnabled(false);

    for (int c = 0; c < cols; ++c) {
        table->horizontalHeader()->setSectionResizeMode(c, QHeaderView::Stretch);
    }
    
    for(int row=0; row<rows; ++row) {
        for(int col=0; col<cols; ++col){
            QTableWidgetItem* tableItem = new QTableWidgetItem();
            tableItem->setFlags(tableItem->flags() ^ Qt::ItemIsEditable);
            tableItem->setTextAlignment(Qt::AlignRight);
            tableItem->setText("--");
            table->setItem(row, col, tableItem);
        }
    }
    
    return table;
}
コード例 #17
0
ファイル: qgsmessagelogviewer.cpp プロジェクト: Aladar64/QGIS
void QgsMessageLogViewer::logMessage( QString message, QString tag, QgsMessageLog::MessageLevel level )
{
#ifdef ANDROID
  mCount++;
#else
  mButton->setToolTip( tr( "%1 message(s) logged." ).arg( mCount++ ) );
#endif

  if ( !isVisible() && level > QgsMessageLog::INFO )
  {
    mButton->show();
    if ( mShowToolTips )
      QToolTip::showText( mButton->mapToGlobal( QPoint( 0, 0 ) ), mButton->toolTip() );
  }

  if ( tag.isNull() )
    tag = tr( "General" );

  int i;
  for ( i = 0; i < tabWidget->count() && tabWidget->tabText( i ) != tag; i++ )
    ;

  QTableWidget *w;
  if ( i < tabWidget->count() )
  {
    w = qobject_cast<QTableWidget *>( tabWidget->widget( i ) );
    tabWidget->setCurrentIndex( i );
  }
  else
  {
    w = new QTableWidget( 0, 3, this );
    w->verticalHeader()->setDefaultSectionSize( 16 );
    w->verticalHeader()->setResizeMode( QHeaderView::ResizeToContents );
    w->verticalHeader()->setVisible( false );
    w->setGridStyle( Qt::DotLine );
    w->setEditTriggers( QAbstractItemView::NoEditTriggers );
    w->setHorizontalScrollMode( QAbstractItemView::ScrollPerPixel );
    w->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
    w->setHorizontalHeaderLabels( QStringList() << tr( "Timestamp" ) << tr( "Message" ) << tr( "Level" ) );
    tabWidget->addTab( w, tag );

    tabWidget->setCurrentIndex( tabWidget->count() - 1 );
  }

  int n = w->rowCount();

  w->setRowCount( n + 1 );
  QTableWidgetItem *item = new QTableWidgetItem( QDateTime::currentDateTime().toString( Qt::ISODate ) );
  w->setItem( n, 0, item );
  w->setItem( n, 1, new QTableWidgetItem( message ) );
  w->setItem( n, 2, new QTableWidgetItem( QString::number( level ) ) );
  w->scrollToBottom();

  w->horizontalHeader()->resizeSections( QHeaderView::ResizeToContents );
}
コード例 #18
0
ファイル: parameterwin.cpp プロジェクト: niuyuxin/crsui
void ParameterWin::creatTableItem(command_attr_t *commands, quint16 size)
{
    QVector <command_attr_t *> cVector;
    QStringList table;
    qDebug() << "command size = " << size;
    for (int i = 0; i < size; ++i) {
        if (!commands[i].tableName.isEmpty()) {
            if (!table.contains(commands[i].tableName)) {
                table.append(commands[i].tableName);
            }
        }
    }
    for (int i = 0; i < table.size(); ++i) {
        cVector.clear();
        for (int j = 0; j < size; ++j) {
            if (commands[j].tableName == table.at(i)) {
                cVector.append(&commands[j]);
            }
        }
        QTableWidget *tableWidget = new QTableWidget;
        tableWidgetVector.append(tableWidget);
        QStringList row, column;
        for (int i = 0; i < cVector.size(); ++i) {
            if (!column.contains(cVector[i]->paraName)) {
                column << cVector[i]->paraName;
            }
            if (!row.contains(cVector[i]->columnName)) {
                row << cVector[i]->columnName;
            }
        }
        tableWidget->setColumnCount(row.size());
        tableWidget->setRowCount(column.size());
        tableWidget->setHorizontalHeaderLabels(row);
        tableWidget->setVerticalHeaderLabels(column);
        for (int i = 0, k = 0; i < row.size(); ++i) {
            for (int j = 0; j < column.size(); ++j) {
                Cell *item = new Cell(cVector[k]);
                item->setTextAlignment(Qt::AlignCenter);
                item->setToolTip(cVector[k]->comment);
                item->setText(cVector[k++]->paraValue.toString());
                tableWidget->setItem(j, i, item);
            }
        }
        connect(tableWidget, SIGNAL(itemChanged(QTableWidgetItem *)),
                this, SLOT(somethingChanged(QTableWidgetItem *)));
        if ((cVector[0]->paraAttr&WRITE) != WRITE) {
            tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
        }
        tabWidget->addTab(tableWidget, cVector[0]->tableName);
    }

}
コード例 #19
0
ファイル: about_dialog.cpp プロジェクト: jelmer/wireshark
static void plugins_add_description(const char *name, const char *version,
                                    const char *types, const char *filename,
                                    void *user_data )
{

    QTableWidget *tbPlugins = (QTableWidget *)user_data;
    tbPlugins->setRowCount(tbPlugins->rowCount() + 1);

    tbPlugins->setItem(tbPlugins->rowCount()-1, 0, new QTableWidgetItem(name));
    tbPlugins->setItem(tbPlugins->rowCount()-1, 1, new QTableWidgetItem(version));
    tbPlugins->setItem(tbPlugins->rowCount()-1, 2, new QTableWidgetItem(types));
    tbPlugins->setItem(tbPlugins->rowCount()-1, 3, new QTableWidgetItem(filename));
}
コード例 #20
0
ファイル: debugpanel.cpp プロジェクト: Ali-I/CsoundQt
void DebugPanel::setVariableList(QVector<QVariantList> varList)
{
    QTableWidget *table = ui->stackTableWidget;
    table->setRowCount(0);
    int row = 0, column = 0;
    foreach(QVariantList var, varList) {
        table->insertRow(table->rowCount());
        column = 0;
        foreach(QVariant part, var) {
            QTableWidgetItem *item = new QTableWidgetItem(part.toString());
            table->setItem(row, column, item);
            column++;
        }
コード例 #21
0
void MainWindow::busMonitorAddItem( bool isRequest,
					uint8_t slave,
					uint8_t func,
					uint16_t addr,
					uint16_t nb,
					uint16_t expectedCRC,
					uint16_t actualCRC )
{
	QTableWidget * bm = ui->busMonTable;
	const int rowCount = bm->rowCount();
	bm->setRowCount( rowCount+1 );

	QTableWidgetItem * ioItem = new QTableWidgetItem( isRequest ? tr( "Req >>" ) : tr( "<< Resp" ) );
	QTableWidgetItem * slaveItem = new QTableWidgetItem( QString::number( slave ) );
	QTableWidgetItem * funcItem = new QTableWidgetItem( QString::number( func ) );
	QTableWidgetItem * addrItem = new QTableWidgetItem( QString::number( addr ) );
	QTableWidgetItem * numItem = new QTableWidgetItem( QString::number( nb ) );
	QTableWidgetItem * crcItem = new QTableWidgetItem;
	if( func > 127 )
	{
		addrItem->setText( QString() );
		numItem->setText( QString() );
		funcItem->setText( tr( "Exception (%1)" ).arg( func-128 ) );
		funcItem->setForeground( Qt::red );
	}
	else
	{
		if( expectedCRC == actualCRC )
		{
			crcItem->setText( QString().sprintf( "%.4x", actualCRC ) );
		}
		else
		{
			crcItem->setText( QString().sprintf( "%.4x (%.4x)", actualCRC, expectedCRC ) );
			crcItem->setForeground( Qt::red );
		}
	}
	ioItem->setFlags( ioItem->flags() & ~Qt::ItemIsEditable );
	slaveItem->setFlags( slaveItem->flags() & ~Qt::ItemIsEditable );
	funcItem->setFlags( funcItem->flags() & ~Qt::ItemIsEditable );
	addrItem->setFlags( addrItem->flags() & ~Qt::ItemIsEditable );
	numItem->setFlags( numItem->flags() & ~Qt::ItemIsEditable );
	crcItem->setFlags( crcItem->flags() & ~Qt::ItemIsEditable );
	bm->setItem( rowCount, 0, ioItem );
	bm->setItem( rowCount, 1, slaveItem );
	bm->setItem( rowCount, 2, funcItem );
	bm->setItem( rowCount, 3, addrItem );
	bm->setItem( rowCount, 4, numItem );
	bm->setItem( rowCount, 5, crcItem );
	bm->verticalScrollBar()->setValue( 100000 );
}
コード例 #22
0
ファイル: Table.cpp プロジェクト: fferri/v_repExtCustomUI
QWidget * Table::createQtWidget(Proxy *proxy, UIProxy *uiproxy, QWidget *parent)
{
    QTableWidget *tablewidget = new TableWidget(this, parent);
    tablewidget->setEnabled(enabled);
    tablewidget->setVisible(visible);
    tablewidget->setStyleSheet(QString::fromStdString(style));
    size_t rowcount = rows.size(), columncount = 0;
    for(size_t i = 0; i < rowcount; i++)
        columncount = std::max(columncount, rows[i].size());
    tablewidget->setRowCount(rowcount);
    tablewidget->setColumnCount(columncount);
    tablewidget->horizontalHeader()->setVisible(show_horizontal_header);
    tablewidget->verticalHeader()->setVisible(show_vertical_header);
    tablewidget->setShowGrid(show_grid);
    QStringList qtHorizontalHeader;
    for(size_t i = 0; i < horizontalHeader.size(); i++)
        qtHorizontalHeader << QString::fromStdString(horizontalHeader[i]);
    tablewidget->setHorizontalHeaderLabels(qtHorizontalHeader);
    QStringList qtVerticalHeader;
    for(size_t i = 0; i < verticalHeader.size(); i++)
        qtVerticalHeader << QString::fromStdString(verticalHeader[i]);
    tablewidget->setVerticalHeaderLabels(qtVerticalHeader);
    if(autosize_horizontal_header)
        tablewidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
    if(autosize_vertical_header)
        tablewidget->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
    if(sortable)
        tablewidget->setSortingEnabled(true);
    for(size_t row = 0; row < rowcount; row++)
    {
        for(size_t column = 0; column < rows[row].size(); column++)
        {
            TableItem &item = rows[row][column];
            QTableWidgetItem *qtwitem = new QTableWidgetItem(QString::fromStdString(item.text));
            if(item.editable)
                qtwitem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
            else
                qtwitem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
            tablewidget->setItem(row, column, qtwitem);
        }
    }
    tablewidget->setSelectionBehavior(selectionBehavior);
    tablewidget->setSelectionMode(selectionMode);
    QObject::connect(tablewidget, &QTableWidget::cellActivated, uiproxy, &UIProxy::onCellActivate);
    QObject::connect(tablewidget, &QTableWidget::cellChanged, uiproxy, &UIProxy::onCellActivate);
    QObject::connect(tablewidget, &QTableWidget::itemSelectionChanged, uiproxy, &UIProxy::onTableSelectionChange);
    setQWidget(tablewidget);
    setEditable(editable);
    setProxy(proxy);
    return tablewidget;
}
コード例 #23
0
/**
  * @brief apply query records <resolver>;<domain>;<nic>;<latency>;<error>;<type>;<start>;<end>;
  */
void OpenNICQueryHistoryDialog::history(QStringList& queries)
{
	QTableWidget* table = ui->queryHistory;
	table->setRowCount(queries.count());
	for(int row=0; row < queries.count(); row++)
	{
		QStringList columns = queries[row].split(";");
		for(int col=0; col < columns.count(); col++)
		{
			table->setItem(row,col,new QTableWidgetItem(columns[col]));
		}
	}
	table->resizeColumnsToContents();
	table->resizeRowsToContents();
}
コード例 #24
0
void Form_PlatformConfiguration::LoadConfig(const QObjectList &q)
{
    for(int i=0;i<q.length();i++)
    {

        if(!q.at(i)->children().empty())
        {
            LoadConfig(q.at(i)->children());
        }

        QObject* obj = q.at(i);

        if (obj->inherits("QLineEdit"))
        {
            QLineEdit *b = qobject_cast<QLineEdit*>(obj);
            QString Name = obj->objectName();
            QDomNode node = STT_Global::FindXml(doc_config,Name);
            if(!node.isNull() ) b->setText(node.attributes().namedItem("Value").nodeValue() );

        }
        else if (obj->inherits("QGroupBox"))
        {
            QGroupBox* b = qobject_cast<QGroupBox*>(obj);
            QDomNode node = STT_Global::FindXml(doc_config,b->objectName());
            if(!node.isNull() ) b->setChecked( node.attributes().namedItem("Value").nodeValue() == "1" ? true:false);
        }
        else if (obj->inherits("QTableWidget"))
        {
            QTableWidget* b = qobject_cast<QTableWidget*>(obj);
            QDomNode node = STT_Global::FindXml(doc_config,b->objectName());
            if( !node.isNull() )
            {
              int Value_R =  node.attributes().namedItem("Value_R").nodeValue().toInt();
              int Value_C =  node.attributes().namedItem("Value_C").nodeValue().toInt();
              b->setRowCount(Value_R);

              for(int i =0 ; i<Value_R ;i++)
              {
                  QDomNode item= node.childNodes().at(i);
                  for(int j=0 ;j < Value_C ; j++)
                  {
                      b->setItem(i, j, new QTableWidgetItem(item.attributes().namedItem("C"+QString::number(j)).nodeValue()));
                  }
              }
            }
        }
    }
}
コード例 #25
0
ファイル: opennic.cpp プロジェクト: 8bitgeek/OpenNIC-Wizard
/**
  * @brief Updates the resolver pool display.
  */
void OpenNIC::updateResolverPool(QStringList resolverPool)
{
	/* @brief <status>;<score>;<kind>;<hostAddress>; */

	QTableWidget* table = ui->resolverPoolTable;
	double minScore,maxScore;
	scoreMinMax(resolverPool, minScore, maxScore);
	table->setRowCount(resolverPool.count());
	for(int row=0; row < resolverPool.count(); row++ )
	{
		QStringList elements = resolverPool.at(row).split(";");
		QString ip		= elements.at(3);
		QString kind	= elements.at(2);
		QString score	= elements.at(1);
		QString status	= elements.at(0);
		QString statusIcon;
		if (status == "R")
		{
			status = tr("FAIL");
			statusIcon = ":/images/status-red.png";
		}
		else if (status == "G")
		{
			status = tr("OK");
			statusIcon = ":/images/status-green.png";
		}
		else if (status == "Y")
		{
			status = tr("WARN");
			statusIcon = ":/images/status-yellow.png";
		}
		table->setItem(row,3,new QTableWidgetItem(ip));
		table->setItem(row,2,new QTableWidgetItem(kind));
#if 0
		table->setItem(row,1,new QTableWidgetItem(score));
#else
		QProgressBar* bar = new QProgressBar();
		bar->setRange((int)(minScore*1000.0),(int)(maxScore*1000.0));
		bar->setValue((int)(score.toDouble()*1000.0));
		table->setCellWidget(row,1,bar);
#endif
		table->setItem(row,0,new QTableWidgetItem(QIcon(statusIcon),status));
	}
	table->resizeColumnsToContents();
	table->resizeRowsToContents();
	table->setSortingEnabled(true);
	table->sortByColumn(1,Qt::DescendingOrder);
}
コード例 #26
0
ファイル: pictoController.cpp プロジェクト: hiroMTB/picto
void pictoController::addPresetFromPrmData(PrmData p){
    QTableWidget * t = ui->tableWidget;
    const int rowNum= t->rowCount();
    t->setRowCount(rowNum+1);
    t->setItem(rowNum,0,new QTableWidgetItem(p.message.c_str()));
    t->setItem(rowNum,1,new QTableWidgetItem(ofToString(p.fontSize).c_str()));
    t->setItem(rowNum,2,new QTableWidgetItem(ofToString(p.lineHeight).c_str()));
    t->setItem(rowNum,3,new QTableWidgetItem(ofToString(p.letterSpacing).c_str()));
    t->setItem(rowNum,4,new QTableWidgetItem(ofToString(p.fontRandomness).c_str()));
    t->setItem(rowNum,5,new QTableWidgetItem(ofToString(p.iconSize).c_str()));
    t->setItem(rowNum,6,new QTableWidgetItem(ofToString(p.iconDensity).c_str()));
    t->setItem(rowNum,7,new QTableWidgetItem(ofToString(p.speed).c_str()));
    t->setItem(rowNum,8,new QTableWidgetItem(ofToString(p.accel).c_str()));
    t->setItem(rowNum,9,new QTableWidgetItem(ofToString(p.vibration).c_str()));
    t->setItem(rowNum,10,new QTableWidgetItem(ofToString(p.holdTime).c_str()));
}
コード例 #27
0
void
TransitionEditorWindow::updatePointsTable()
{
	if (model_ == nullptr) return;
	if (transition_ == nullptr) return;

	QTableWidget* table = ui_->pointsTable;

	SignalBlocker blocker(table);

	table->setRowCount(pointList_.size());
	for (unsigned int i = 0, size = pointList_.size(); i < size; ++i) {
		const auto& point = pointList_[i];
		unsigned int column = 0;

		std::unique_ptr<QTableWidgetItem> item(new QTableWidgetItem(QString("%1 - %2").arg(point.type).arg(typeNames[point.type])));
		item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
		table->setItem(i, column++, item.release());

		item.reset(new QTableWidgetItem);
		item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
		item->setData(Qt::DisplayRole, point.value);
		table->setItem(i, column++, item.release());

		item.reset(new QTableWidgetItem);
		item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
		item->setCheckState(point.isPhantom ? Qt::Checked : Qt::Unchecked);
		table->setItem(i, column++, item.release());

		if (!special_) {
			item.reset(new QTableWidgetItem);
			item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
			item->setCheckState(point.hasSlope ? Qt::Checked : Qt::Unchecked);
			table->setItem(i, column++, item.release());

			item.reset(new QTableWidgetItem);
			item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
			item->setData(Qt::DisplayRole, point.slope);
			table->setItem(i, column++, item.release());
		}

		const std::shared_ptr<TRMControlModel::Equation> timeExpression(point.timeExpression.lock());
		item.reset(new QTableWidgetItem(timeExpression ? timeExpression->name().c_str() : ""));
		item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
		table->setItem(i, column, item.release());
	}
}
コード例 #28
0
ファイル: main.cpp プロジェクト: MarianMMX/MarianMMX
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();
}
コード例 #29
0
ファイル: votepage.cpp プロジェクト: brossi/nu-automake
void VotePage::updateLiquidity()
{
    unsigned char cUnit = 'B';
    LiquidityTotal total;
    QMap<QString, LiquidityTotal> tierMap;
    {
        LOCK(cs_mapLiquidityInfo);

        BOOST_FOREACH(const PAIRTYPE(const CLiquiditySource, CLiquidityInfo)& item, mapLiquidityInfo)
        {
            const CLiquidityInfo& info = item.second;
            if (info.cUnit == cUnit)
            {
                total += info;
                QString tier = QString::fromStdString(info.GetTier());
                tierMap[tier] += info;
            }
        }
    }

    QTableWidget* table = ui->liquidity;
    table->setRowCount(0);

    QMap<QString, LiquidityTotal>::const_iterator it = tierMap.constBegin();
    while (it != tierMap.constEnd())
    {
        const QString& tier = it.key();
        const LiquidityTotal& liquidity = it.value();

        QString label;
        if (tier == "")
            label = tr("Unknown tier");
        else
            label = tr("Tier %1").arg(tier);
        liquidity.AddToTable(table, label);

        it++;
    }

    total.AddToTable(table, tr("Total"));

    table->setVisible(false);
    table->resizeColumnToContents(0);
    table->setVisible(true);
}
コード例 #30
0
/** Loads the settings for this page */
void ShareManager::load()
{
    if(isLoading)
        return ;

    isLoading = true;
//    std::cerr << "ShareManager:: In load !!!!!" << std::endl ;

    std::list<SharedDirInfo>::const_iterator it;
    std::list<SharedDirInfo> dirs;
    rsFiles->getSharedDirectories(dirs);

    /* get a link to the table */
    QTableWidget *listWidget = ui.shareddirList;

    /* set new row count */
    listWidget->setRowCount(dirs.size());

    int row=0 ;
    for(it = dirs.begin(); it != dirs.end(); ++it,++row)
    {
        listWidget->setItem(row, COLUMN_PATH, new QTableWidgetItem(QString::fromUtf8((*it).filename.c_str())));
        listWidget->setItem(row, COLUMN_VIRTUALNAME, new QTableWidgetItem(QString::fromUtf8((*it).virtualname.c_str())));

		  GroupFlagsWidget *widget = new GroupFlagsWidget(NULL,(*it).shareflags);

		  listWidget->setRowHeight(row, 32);
		  listWidget->setCellWidget(row, COLUMN_SHARE_FLAGS, widget);

		  listWidget->setItem(row, COLUMN_GROUPS, new QTableWidgetItem()) ;
		  listWidget->item(row,COLUMN_GROUPS)->setBackgroundColor(QColor(183,236,181)) ;

		  //connect(widget,SIGNAL(flagsChanged(FileStorageFlags)),this,SLOT(updateFlags())) ;
    }

	 listWidget->setColumnWidth(COLUMN_SHARE_FLAGS,132) ;

    //ui.incomingDir->setText(QString::fromStdString(rsFiles->getDownloadDirectory()));

    listWidget->update(); /* update display */
    update();

    isLoading = false ;
    updateGroups();
}