Exemplo n.º 1
1
/**
* @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();

}
Exemplo n.º 2
0
InformationPanel::InformationPanel(QWidget *parent)
: ConfiguratorPanel(false, parent) {
	_name = "Information";
	_icon = QIcon(":/res/icons/info.png");
	setHeadline("Information");
	setDescription("System paths and variables");

	QVBoxLayout *l = new QVBoxLayout;
	l->setMargin(0);
	setLayout(l);

	QTableWidget *table = new QTableWidget;
	table->setFrameShape(QFrame::NoFrame);
	table->setColumnCount(2);
	table->verticalHeader()->setVisible(false);
	table->horizontalHeader()->setStretchLastSection(true);
	table->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
	table->setHorizontalHeaderLabels(QStringList() << "Name" << "Value");
	table->setAlternatingRowColors(true);
	table->setSelectionMode(QAbstractItemView::NoSelection);

	l->addWidget(table);

	Seiscomp::Environment *env = Seiscomp::Environment::Instance();
	addRow(table, "PATH", getenv("PATH"));
	addRow(table, "ROOTDIR", env->installDir().c_str());
	addRow(table, "DEFAULTCONFIGDIR", env->globalConfigDir().c_str());
	addRow(table, "SYSTEMCONFIGDIR", env->appConfigDir().c_str());
	addRow(table, "CONFIGDIR", env->configDir().c_str());
	addRow(table, "LOGDIR", env->logDir().c_str());
	addRow(table, "DATADIR", env->shareDir().c_str());

	table->resizeColumnsToContents();
}
Exemplo n.º 3
0
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();
}
Exemplo n.º 4
0
void Table::setColumnCount(int count, bool suppressSignals)
{
    QTableWidget *tablewidget = static_cast<QTableWidget*>(getQWidget());
    bool oldSignalsState = tablewidget->blockSignals(suppressSignals);
    tablewidget->setColumnCount(count);
    tablewidget->blockSignals(oldSignalsState);
}
Exemplo n.º 5
0
ParamCompareDialog::ParamCompareDialog(QMap<QString, UASParameter* >& paramaterList,
                                       const QString& filename, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ParamCompareDialog),
    m_currentList(&paramaterList),
    m_newList(new QMap<QString, UASParameter*>()),
    m_fileToCompare(filename)
{
    ui->setupUi(this);

    QStringList headerList;
    headerList << tr("Parameter") << tr("Value") << tr("New Value") << tr("Use");

    QTableWidget* table = ui->compareTableWidget;
    table->setColumnCount(headerList.count());
    table->setHorizontalHeaderLabels(headerList);
    table->setSelectionBehavior(QAbstractItemView::SelectRows);
    table->setAlternatingRowColors(true);
    table->setColumnWidth(PCD_COLUMN_CHECKBOX, 40);

    initConnections();

    if(filename.count()>0){
        QTimer::singleShot(200, this, SLOT(loadParameterWithFile()));
    }

}
Exemplo n.º 6
0
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++;
    }
Exemplo n.º 7
0
ServerTab::ServerTab()
{
    //
    QLabel *legendLabel = new QLabel("Liste des clients connectés au serveur.");
    legendLabel->setFixedHeight(40);

    // TabWidget

    QTableWidget *tableWidget = new QTableWidget();
    tableWidget->setColumnCount(6);

    // resize to contents
    tableWidget->setColumnWidth(0, 300);
    tableWidget->setColumnWidth(4, 120);

    QStringList listHeaders;
    listHeaders << "Nom du client" << "ID de connexion" << "Adresse IP" << "Statut" << "Début de connexion" << "Fin de connexion";
    tableWidget->setHorizontalHeaderLabels(listHeaders);
    tableWidget->horizontalHeaderItem(0)->setTextAlignment(Qt::AlignLeft);


    // Layering

    QVBoxLayout *vl = new QVBoxLayout();
    setLayout(vl);
    vl->addWidget(legendLabel);
    vl->addWidget(tableWidget);
}
Exemplo n.º 8
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();
}
Exemplo n.º 9
0
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();
}
Exemplo n.º 10
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;
}
Exemplo n.º 11
0
AppHistoryTab::AppHistoryTab()
{

    //

    QLabel *legendLabel = new QLabel("Historique des applications depuis la connexion au serveur.");
    legendLabel->setFixedHeight(40);


    // TabWidget

    QTableWidget *tableWidget = new QTableWidget();
    tableWidget->setColumnCount(6);

    // resize to contents
    tableWidget->setColumnWidth(0, 300);

    QStringList listHeaders;
    listHeaders << "Nom" << "PID" << "Statut" << "UID" << "Date de début" << "Date de fin";
    tableWidget->setHorizontalHeaderLabels(listHeaders);
    tableWidget->horizontalHeaderItem(0)->setTextAlignment(Qt::AlignLeft);


    // Layering

    QVBoxLayout *vl = new QVBoxLayout();
    setLayout(vl);
    vl->addWidget(legendLabel);
    vl->addWidget(tableWidget);
}
Exemplo n.º 12
0
QTableWidget *StManagerStudyListComp::createStudyTable ()
{
  QTableWidget *table  = new QTableWidget;

  table->setSelectionBehavior( QAbstractItemView::SelectRows );
  table->setSelectionMode( QAbstractItemView::SingleSelection );
  table->setEditTriggers( QAbstractItemView::NoEditTriggers );

  QStringList labels;
  for ( int i = 0; i < ATTRIBUTE_NUMBER; i++ ) {
    labels << tr( attributeNames[i] );
  }
  
  table->setColumnCount( labels.size() + 1 );
  table->setHorizontalHeaderLabels( labels );
  table->setColumnHidden( ATTRIBUTE_NUMBER, true );

  for ( int i = 0; i < ATTRIBUTE_NUMBER; i++ ) 
  {
    if ( attributeResizes[i] ) {
      table->horizontalHeader()->setResizeMode( i, QHeaderView::ResizeToContents );
    }
  }

  connect( table, SIGNAL(itemSelectionChanged()), this, SLOT(setEnabledView()) );
  connect( table, SIGNAL(itemDoubleClicked( QTableWidgetItem * )), this, SLOT(view()) );

  return table;
}
Exemplo n.º 13
0
void MainWindow::clearObjectTable()
{
    QTableWidget *table = ui->objectsTableWidget;
    table->clear();
    table->setRowCount(0);
    table->setColumnCount(0);
}
Exemplo n.º 14
0
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;
}
Exemplo n.º 15
0
Arquivo: main.cpp Projeto: 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();
}
void TrainLinePanel::__initTableHeader()
{
    int listLineCount = ui->listWidget->count();
    for(int i = 0; i < listLineCount;i++)
    {
        QTableWidget *tableWidget = new QTableWidget;
        tableWidget->setAlternatingRowColors(true);
        tableWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
        tableWidget->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);

    //    connect(tableWidget,SIGNAL(doubleClicked(QModelIndex)),keyboard,SLOT(show(QModelIndex)));

        tableWidget->verticalHeader()->setHidden(true);


        tableWidget->setColumnCount(10);
        tableWidget->setColumnHidden(9,true);
        tableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
        tableWidget->horizontalHeader()->setMinimumHeight(30);
        tableWidget->horizontalHeader()->setMinimumSectionSize(140);
        QTableWidgetItem* item = new QTableWidgetItem("Station number");
        item->setTextAlignment(Qt::AlignHCenter);
        tableWidget->setHorizontalHeaderItem(0,item);
        item = new QTableWidgetItem("Station id");
        item->setTextAlignment(Qt::AlignHCenter);
        tableWidget->setHorizontalHeaderItem(1,item);
        item = new QTableWidgetItem("Name(EN)");
        item->setTextAlignment(Qt::AlignHCenter);
        tableWidget->setHorizontalHeaderItem(2,item);
        item = new QTableWidgetItem("Name(TH)");
        item->setTextAlignment(Qt::AlignHCenter);
        tableWidget->setHorizontalHeaderItem(3,item);
        item = new QTableWidgetItem("Start time");
        item->setTextAlignment(Qt::AlignHCenter);
        tableWidget->setHorizontalHeaderItem(4,item);
        item = new QTableWidgetItem("Arrive time");
        item->setTextAlignment(Qt::AlignHCenter);
        tableWidget->setHorizontalHeaderItem(5,item);

        item = new QTableWidgetItem("Lng");
        item->setTextAlignment(Qt::AlignHCenter);
        tableWidget->setHorizontalHeaderItem(6,item);

        item = new QTableWidgetItem("Lat");
        item->setTextAlignment(Qt::AlignHCenter);
        tableWidget->setHorizontalHeaderItem(7,item);

        item = new QTableWidgetItem("Sea level");
        item->setTextAlignment(Qt::AlignHCenter);
        tableWidget->setHorizontalHeaderItem(8,item);

        item = new QTableWidgetItem("Rowid");
        item->setTextAlignment(Qt::AlignHCenter);
        tableWidget->setHorizontalHeaderItem(9,item);

        ui->stackedWidget->addWidget(tableWidget);
    }
//    connect(tableWidget,SIGNAL(itemChanged(QTableWidgetItem*)),this,SLOT(updateDatabase(QTableWidgetItem*)));
}
Exemplo n.º 17
0
void TableView::reset()
{
	INFO("Reset")
    QTableWidget* table =  getTableWidget();
    if(0!=table)
    {
        table->clear();
      //  QStringList headers = _header.split(";", QString::SkipEmptyParts);
        table->setColumnCount(_header.count());
        table->setHorizontalHeaderLabels(_header);
    }
}
Exemplo n.º 18
0
QTableWidget *StManagerStudyListComp::createSeriesSelectionTable ()
{
  QTableWidget *seriesTable = new QTableWidget;

  seriesTable->setSelectionMode( QAbstractItemView::SingleSelection );
  seriesTable->setEditTriggers( QAbstractItemView::NoEditTriggers );
  seriesTable->setColumnCount( 1 );
  seriesTable->horizontalHeader()->setResizeMode( QHeaderView::Stretch );
  seriesTable->horizontalHeader()->hide();

  return seriesTable;
}
Exemplo n.º 19
0
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);
    }

}
Exemplo n.º 20
0
void initNogoodTable(QTableWidget& ng_table) {
  ng_table.setEditTriggers(QAbstractItemView::NoEditTriggers);

  ng_table.setColumnCount(3);

  QStringList table_header;
  table_header << "Id" << "Occurrence" << "Literals";
  ng_table.setHorizontalHeaderLabels(table_header);
  ng_table.setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
  ng_table.setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);


}
Exemplo n.º 21
0
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;
}
Exemplo n.º 22
0
void MainWindow::updateObjectTable(int objId)
{
    if(noEmit)
        return;

    if(objId == -2 || levelObjects.count() <= objId)
    {
        clearObjectTable();
        return;
    }

    if(objId == -1)
        return;

    QTableWidget *table = ui->objectsTableWidget;

    int rowCount = 0;
    table->setColumnCount(2);
    table->setRowCount(0);

    QMap<QString, QVariant>::const_iterator it;
    for (it = levelObjects.at(objId).constBegin(); it != levelObjects.at(objId).constEnd(); ++it)
    {
        rowCount++;
        table->setRowCount(rowCount);

        table->setItem(rowCount-1, 0, new QTableWidgetItem(it.key()));

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

    QString rotationStr = levelObjects[objId].value("rotation", "nil").toString();
    if(rotationStr != "nil"){
        int rotation = rotationStr.toInt();
        ui->rotationLabel->setText(QString("Rotation - " + QString::number(rotation) + " degrees").toAscii());

        ui->rotationSlider->setValue(rotation / 3.6);
    }
}
Exemplo n.º 23
0
void TableView::setHeader(QStringList value)
{
    //_header = value;
    QTableWidget* table =  getTableWidget();
    if(0!=table)
    {
       // QStringList headers = _header.split(";", QString::SkipEmptyParts);
        table->setColumnCount(value.count());
        table->setHorizontalHeaderLabels(value);
        _header = value;
      //  table->setVerticalHeaderItem();
      //  table->setVerticalHeaderLabels(_header.split(";", QString::SkipEmptyParts));
    }
  //  emit send(esp::init(new QString(value),0,""));
}
Exemplo n.º 24
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();
}
Exemplo n.º 25
0
void
CLOAD_WORKSHEET::
CreateTable(QTabWidget * tabWidget, QString tabName, quint64 rowCount)
{
    quint64 columnCount = 12;

    // Table attributes
    QTableWidget * tableWidget = new QTableWidget();
    QHeaderView * header = tableWidget->horizontalHeader();
    header->setSectionResizeMode(QHeaderView::Stretch);
    header->setStretchLastSection(true);
    tableWidget->setAlternatingRowColors(true);
    tableWidget->setRowCount(rowCount);
    tableWidget->setColumnCount(columnCount);

    // set table column header
    tableWidget->setHorizontalHeaderItem(0,new QTableWidgetItem("Name"));
    tableWidget->setHorizontalHeaderItem(1,new QTableWidgetItem("Value"));
    tableWidget->setHorizontalHeaderItem(2,new QTableWidgetItem("Value Range"));
    tableWidget->setHorizontalHeaderItem(3,new QTableWidgetItem("    Type   "));
    tableWidget->setHorizontalHeaderItem(4,new QTableWidgetItem("Conversion"));
    tableWidget->setHorizontalHeaderItem(5,new QTableWidgetItem("Byte Offset"));
    tableWidget->setHorizontalHeaderItem(6,new QTableWidgetItem("Bit Offset"));
    tableWidget->setHorizontalHeaderItem(7,new QTableWidgetItem("Bit Size"));
    tableWidget->setHorizontalHeaderItem(8,new QTableWidgetItem("Field Used"));
    tableWidget->setHorizontalHeaderItem(9,new QTableWidgetItem("Low Byte First"));
    tableWidget->setHorizontalHeaderItem(10,new QTableWidgetItem("Group"));
    tableWidget->setHorizontalHeaderItem(11,new QTableWidgetItem("Encoding Factor"));

    tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
    tableWidget->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
    tableWidget->horizontalHeader()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
    tableWidget->horizontalHeader()->setSectionResizeMode(4, QHeaderView::ResizeToContents);
    tableWidget->horizontalHeader()->setSectionResizeMode(5, QHeaderView::ResizeToContents);
    tableWidget->horizontalHeader()->setSectionResizeMode(6, QHeaderView::ResizeToContents);
    tableWidget->horizontalHeader()->setSectionResizeMode(7, QHeaderView::ResizeToContents);
    tableWidget->horizontalHeader()->setSectionResizeMode(8, QHeaderView::ResizeToContents);
    tableWidget->horizontalHeader()->setSectionResizeMode(9, QHeaderView::ResizeToContents);
    tableWidget->horizontalHeader()->setSectionResizeMode(10, QHeaderView::ResizeToContents);
    tableWidget->horizontalHeader()->setSectionResizeMode(11, QHeaderView::ResizeToContents);

    // add tab
    tabWidget->addTab(tableWidget, tabName);    
}
Exemplo n.º 26
0
ParamCompareDialog::ParamCompareDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ParamCompareDialog),
    m_newList(new QMap<QString, UASParameter*>())
{
    ui->setupUi(this);

    QStringList headerList;
    headerList << tr("Parameter") << tr("Value") << tr("New Value") << tr("Use");

    QTableWidget* table = ui->compareTableWidget;
    table->setColumnCount(headerList.count());
    table->setHorizontalHeaderLabels(headerList);
    table->setSelectionBehavior(QAbstractItemView::SelectRows);
    table->setAlternatingRowColors(true);
    table->setColumnWidth(PCD_COLUMN_CHECKBOX, 40);

    initConnections();
}
Exemplo n.º 27
0
QListViewItemExt::QListViewItemExt(QTableWidgetItem* item,QString label1,
                                   QString label2,QString label3,
                                   QString label4,QString label5,
                                   QString label6,QString label7,
                                   QString label8)
{
    QTableWidget* parent = item->tableWidget();
    mParent = parent;
    mIndex = -1;
    mHiddenText = QString::null;
    mRow = parent->rowCount();

    parent->insertRow(mRow);
    parent->setColumnCount(8);
    addWidgets(parent, label1, label2, label3, label4, label5, label6,
               label7, label8);
  mIndex = -1;
  mHiddenText = QString::null;
}
Exemplo n.º 28
0
//Это нужно вынести в отдельный класс!
//--->
void MainWindow::fillYearTable(QTableWidget& tableYear)
{
    int j = 0;
    QTableWidgetItem *newItem;
    tableYear.setColumnCount(1);
    for(int i = PASTYEARS; i < FUTUREYEARS; i++)
    {
        tableYear.insertRow(j);
        newItem = new QTableWidgetItem();
        newItem->setText(QString::number(selDate_.year() + i));
        tableYear.setItem(j, 0, newItem);
        if((selDate_.year() + i) == selDate_.year())
            tableYear.item(j, 0)->setBackground(Qt::red);
        else
            tableYear.item(j, 0)->setBackground(Qt::cyan);
        j++;
    }
    standartStuffForAllTables(*ui->twYear);
}
Exemplo n.º 29
0
void MainWindow::fillMonthTable(QTableWidget& tableMonth)
{
    int j = 0;
    QTableWidgetItem *newItem;
    tableMonth.setColumnCount(1);
    for(int i = 1; i < MONTHS+1; i++)
    {
        tableMonth.insertRow(j);
        newItem = new QTableWidgetItem();
        newItem->setText(QString::number(i));
        tableMonth.setItem(j, 0, newItem);
        if(i == selDate_.month())
            tableMonth.item(j, 0)->setBackground(Qt::red);
        else
            tableMonth.item(j, 0)->setBackground(Qt::magenta);
        j++;
    }
    standartStuffForAllTables(*ui->twMonth);
}
Exemplo n.º 30
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),cdadPersonas(0)
{
    ui->setupUi(this);
    //ui->mainToolBar->addAction()
    PersonaController * controller = PersonaController::getInstance();

    crearDialog = new CrearPersonaDialog(this);
    editarDialog = new EditPersonaDialog(this);
    crearDialog->setWindowTitle("Crear Persona");
    setupSignalsAndSlots();
    auto f = [] (Persona*) -> bool {return true;}; // all
    QList<Persona *> all = controller->filter(f);
    int cantidadFilas = all.size();

    QTableWidget *table = ui->tableWidget;
    table->setRowCount(cantidadFilas);
    table->setColumnCount(5);

    QStringList header;
    header << "Id" << "Nombre" << "Direccion" << "Telefono" << "Email";
    table->setHorizontalHeaderLabels(header);
    table->adjustSize();
    initPersonas();
//    for (int i = 0; i < all.size(); i++) {
//        Persona *p = all.at(i);
//        int j = 0;
//        QTableWidgetItem *item = new QTableWidgetItem(QString().setNum(p->id()));
//        table->setItem(i, j++, item);
//        item = new QTableWidgetItem(p->nombre());
//        table->setItem(i, j++, item);

//        item = new QTableWidgetItem(p->direccion());
//        table->setItem(i, j++, item);

//        item = new QTableWidgetItem(p->telefono());
//        table->setItem(i, j++, item);
//    }
//    connect(crearDialog, SIGNAL(personaCreated(Persona*)), this, SLOT(agregarPersonaATable(Persona*)));

}