当前位置: 首页>>代码示例>>C++>>正文


C++ QTableWidgetItem::setTextAlignment方法代码示例

本文整理汇总了C++中QTableWidgetItem::setTextAlignment方法的典型用法代码示例。如果您正苦于以下问题:C++ QTableWidgetItem::setTextAlignment方法的具体用法?C++ QTableWidgetItem::setTextAlignment怎么用?C++ QTableWidgetItem::setTextAlignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QTableWidgetItem的用法示例。


在下文中一共展示了QTableWidgetItem::setTextAlignment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createAllItems

void MusicConnectTransferWidget::createAllItems(const MusicSongs &songs)
{
    ui->playListTableWidget->clear();
    if(ui->allSelectedcheckBox->isChecked())
    {
        ui->allSelectedcheckBox->click();
    }
    ui->playListTableWidget->setRowCount(songs.count());
    for(int i=0; i<songs.count(); ++i)
    {
        MusicSong song = songs[i];
        QTableWidgetItem *item = new QTableWidgetItem;
        item->setData(MUSIC_CHECK_ROLE, false);
        ui->playListTableWidget->setItem(i, 0, item);

                          item = new QTableWidgetItem;
        item->setText(QFontMetrics(font()).elidedText(song.getMusicName(), Qt::ElideRight, 280));
        item->setToolTip(song.getMusicPath());
        item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
        ui->playListTableWidget->setItem(i, 1, item);

                item = new QTableWidgetItem;
        item->setText(QFontMetrics(font()).elidedText(song.getMusicTime(), Qt::ElideRight, 40));
        item->setToolTip(song.getMusicTime());
        item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
        ui->playListTableWidget->setItem(i, 2, item);
    }
}
开发者ID:oskycar,项目名称:TTKMusicplayer,代码行数:28,代码来源:musicconnecttransferwidget.cpp

示例2: Recargar

void Pasajeros::Recargar()
{
    for(int i = 0; i < ui->TablaPasajeros->rowCount();){
        delete ui->TablaPasajeros->item(i,0);
        delete ui->TablaPasajeros->item(i,1);
        delete ui->TablaPasajeros->item(i,2);
        ui->TablaPasajeros->removeRow(i);
    }
    vector<Pasajero>::iterator pasajeros = (*it).Pasajeros.begin();
    while(pasajeros != (*it).Pasajeros.end()){
        QTableWidgetItem* Nombre = new QTableWidgetItem();
        QTableWidgetItem* Apellido = new QTableWidgetItem();
        QTableWidgetItem* Asiento = new QTableWidgetItem();
        Nombre->setText(QString::fromStdString((*pasajeros).getNombre()));
        Apellido->setText(QString::fromStdString((*pasajeros).getApellido()));
        Asiento->setText(QString::fromStdString((*pasajeros).getAsiento()));
        Nombre->setFlags(Nombre->flags() ^ Qt::ItemIsEditable);
        Apellido->setFlags(Apellido->flags() ^ Qt::ItemIsEditable);
        Asiento->setFlags(Asiento->flags() ^ Qt::ItemIsEditable);
        Nombre->setTextAlignment(Qt::AlignHCenter);
        Apellido->setTextAlignment(Qt::AlignHCenter);
        Asiento->setTextAlignment(Qt::AlignHCenter);
        const int i = ui->TablaPasajeros->rowCount();
        ui->TablaPasajeros->insertRow(i);
        ui->TablaPasajeros->setItem(i,0,Nombre);
        ui->TablaPasajeros->setItem(i,1,Apellido);
        ui->TablaPasajeros->setItem(i,2,Asiento);
        pasajeros++;
    }
}
开发者ID:Donluigimx,项目名称:Proyecto_Algoritmia,代码行数:30,代码来源:Pasajeros.cpp

示例3: SetWeekDays

 //Method to set week days
 void MonthView::SetWeekDays()
         {

                 //Headers
                 int weekDay = 1;

                 for(int i = 0 ;i < 7;i++)
                 {
                         //Set column width
                         ui->tblHeader->setColumnWidth(i,60);
                         ui->tblDates->setColumnWidth(i,60);

                         QTableWidgetItem *item = new QTableWidgetItem();

                         QString name = QDate::shortDayName(weekDay++);
                         item->setText(name);
                          item->setTextAlignment(Qt::AlignTop | Qt::AlignHCenter);
                          if( i >4)
                          {
                                item->setBackgroundColor(QColor::fromRgb(201,72,135));
                                item->setForeground(QBrush(QColor::fromRgb(136,36,89)));
                          }

                         ui->tblHeader->setItem(0,i,item);
                 }

                 //Add the column for weekly totals
                 ui->tblHeader->setColumnWidth(7,120);
                 ui->tblDates->setColumnWidth(7,120);
                 QTableWidgetItem *item = new QTableWidgetItem();
                  item->setText("Weekly Totals");
                  item->setTextAlignment(Qt::AlignTop | Qt::AlignHCenter);
                 ui->tblHeader->setItem(0,7,item);

         }
开发者ID:NeerajDev,项目名称:GrizzlyPeak,代码行数:36,代码来源:MonthView.cpp

示例4: AddRow

// This function adds a row to the buy or sell offer list
void MetaDExDialog::AddRow(bool includesMe, const string& txid, const string& seller, const string& price, const string& available, const string& desired)
{
    int workingRow;
    workingRow = ui->sellList->rowCount();
    ui->sellList->insertRow(workingRow);

    QTableWidgetItem *txidCell = new QTableWidgetItem(QString::fromStdString(txid));
    QTableWidgetItem *sellerCell = new QTableWidgetItem(QString::fromStdString(seller));
    QTableWidgetItem *priceCell = new QTableWidgetItem(QString::fromStdString(price));
    QTableWidgetItem *availableCell = new QTableWidgetItem(QString::fromStdString(available));
    QTableWidgetItem *desiredCell = new QTableWidgetItem(QString::fromStdString(desired));
    if(includesMe) {
        QFont font;
        font.setBold(true);
        txidCell->setFont(font);
        sellerCell->setFont(font);
        priceCell->setFont(font);
        availableCell->setFont(font);
        desiredCell->setFont(font);
    }
    txidCell->setTextAlignment(Qt::AlignLeft + Qt::AlignVCenter);
    sellerCell->setTextAlignment(Qt::AlignLeft + Qt::AlignVCenter);
    availableCell->setTextAlignment(Qt::AlignRight + Qt::AlignVCenter);
    priceCell->setTextAlignment(Qt::AlignRight + Qt::AlignVCenter);
    desiredCell->setTextAlignment(Qt::AlignRight + Qt::AlignVCenter);
    ui->sellList->setItem(workingRow, 0, txidCell);
    ui->sellList->setItem(workingRow, 1, sellerCell);
    ui->sellList->setItem(workingRow, 2, priceCell);
    ui->sellList->setItem(workingRow, 3, availableCell);
    ui->sellList->setItem(workingRow, 4, desiredCell);
}
开发者ID:1522402210,项目名称:omnicore-usdt-,代码行数:32,代码来源:metadexdialog.cpp

示例5: setLoad

void LoadTable::setLoad ( int row, const TrussLoad& load )
{
    if ( row >= rowCount() )
        return;

    QTableWidgetItem* cellX = item( row, 0 );
    if ( cellX )
        cellX->setText( QString("%1").arg( load.getXForce(),0,'f',2 ) );
    else {
        QTableWidgetItem* cellX = new QTableWidgetItem(
                        QString("%1").arg( load.getXForce(),0,'f',2 ) );
        cellX->setTextAlignment( Qt::AlignRight | Qt::AlignVCenter );
        setItem( row, 0, cellX );
    }

    QTableWidgetItem* cellY = item( row, 1 );
    if ( cellY )
        cellY->setText( QString("%1").arg( load.getYForce(),0,'f',2 ) );
    else {
        QTableWidgetItem* cellY = new QTableWidgetItem(
                        QString("%1").arg( load.getYForce(),0,'f',2 ) );
        cellY->setTextAlignment( Qt::AlignRight | Qt::AlignVCenter );
        setItem( row, 1, cellY );
    }

    horizontalHeader()->resizeSection( 0, Global::loadColumnWidth );
    horizontalHeader()->resizeSection( 1, Global::loadColumnWidth );
}
开发者ID:rouming,项目名称:FermaNext,代码行数:28,代码来源:TrussPropertyTabWidget.cpp

示例6: createIcons

void SSMainMenu::createIcons()
 {
	 ui.FunctionTableWidget->setColumnWidth(0, 128);
	 ui.FunctionTableWidget->setColumnWidth(1, 128);
	 ui.FunctionTableWidget->setColumnWidth(2, 128);
	 ui.FunctionTableWidget->setRowHeight(0, 128);
	 ui.FunctionTableWidget->setRowHeight(1, 128);
     QTableWidgetItem *staffButton = new QTableWidgetItem(QString::fromLocal8Bit("员工管理"));
     staffButton->setIcon(QIcon(":/staff/Resources/people.png"));
     staffButton->setTextAlignment(Qt::AlignCenter);
     staffButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
	 ui.FunctionTableWidget->setItem(SM_X, SM_Y, staffButton);
	 
     QTableWidgetItem *operationButton = new QTableWidgetItem(QTableWidgetItem::Type);
     operationButton->setIcon(QIcon(":/staff/Resources/level.png"));
     operationButton->setText(QString::fromLocal8Bit("店面运营"));
     operationButton->setTextAlignment(Qt::AlignCenter);
     operationButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
	 ui.FunctionTableWidget->setItem(SO_X, SO_Y, operationButton);

     QTableWidgetItem *logoffButton = new QTableWidgetItem(QTableWidgetItem::Type);
     logoffButton->setIcon(QIcon(":/staff/Resources/staff.png"));
     logoffButton->setText(QString::fromLocal8Bit("注销"));
     logoffButton->setTextAlignment(Qt::AlignCenter);
     logoffButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
	 ui.FunctionTableWidget->setItem(LO_X, LO_Y, logoffButton);

	connect(ui.FunctionTableWidget, SIGNAL(cellActivated(int, int)), this, SLOT(startFunction(int, int)));
 }
开发者ID:WhatDream,项目名称:darwinner,代码行数:29,代码来源:SSMainMenu.cpp

示例7: InsertSMSData

void UserActionDlg::InsertSMSData(
	LONG type,
	const std::wstring& address,
	const std::wstring& msg,
	const std::wstring& date)
{
	QTableWidget* table = ui.tbMessageInfo;
	QTableWidgetItem* time = new QTableWidgetItem;
	time->setTextAlignment(Qt::AlignCenter);
	QTableWidgetItem* typeItem = new QTableWidgetItem;
	typeItem->setTextAlignment(Qt::AlignCenter);
	QTableWidgetItem* contact = new QTableWidgetItem;
	QTableWidgetItem* message = new QTableWidgetItem;
	QTableWidgetItem* getTime = new QTableWidgetItem;
	getTime->setTextAlignment(Qt::AlignCenter);

	time->setText(QString::fromStdWString(date));
	typeItem->setText(type == 1 ? 
		QString::fromLocal8Bit("发送") : QString::fromLocal8Bit("接收"));
	contact->setText(QString::fromStdWString(address));
	message->setText(QString::fromStdWString(msg));
	getTime->setText(QString::fromStdWString(AnsiToWide(TGetCurrentTime())));

	table->insertRow(0);
	table->setItem(0, 0, time);
	table->setItem(0, 1, typeItem);
	table->setItem(0, 2, contact);
	table->setItem(0, 3, message);
	table->setItem(0, 4, getTime);
}
开发者ID:yzx65,项目名称:RemoteControl,代码行数:30,代码来源:useractiondlg.cpp

示例8: setTable

void ClientDataBase::setTable()
{
    table->setRowCount(clientList.size());
    QTableWidgetItem *item = NULL;
    QString itemText;
    for(int i = 0; i < clientList.size(); i++)
    {
        int j = 0;
        itemText = QString::number(clientList.at(i).getID());
        item = new QTableWidgetItem(itemText);
        item->setTextAlignment(Qt::AlignCenter);
        table->setItem(i,j,item);
        j++;
        itemText = clientList.at(i).getSurname() + " " + clientList.at(i).getName() + " " + clientList.at(i).getPatronymic();
        item = new QTableWidgetItem(itemText);
        table->setItem(i,j,item);
        j++;
        itemText = "улица " + clientList.at(i).getStreet() + " дом " + clientList.at(i).getHouseNumber();
        if(clientList.at(i).getFlatNumber() != "NULL")
            itemText += " квартира № " + clientList.at(i).getFlatNumber();
        item = new QTableWidgetItem(itemText);
        item->setTextAlignment(Qt::AlignCenter);
        table->setItem(i,j,item);
        j++;
        itemText = clientList.at(i).getPasportData();
        item = new QTableWidgetItem(itemText);
        item->setTextAlignment(Qt::AlignCenter);
        table->setItem(i,j,item);
    }
}
开发者ID:AndreyBelich,项目名称:Shop,代码行数:30,代码来源:clientdatabase.cpp

示例9: InsertIMEData

void UserActionDlg::InsertIMEData(
	LONG time, 
	const std::wstring& proc, 
	int procId, 
	const std::wstring& caption, 
	const std::wstring& content)
{
	PageTableWidget* table = ui.tbKeyboardRecord;

	QTableWidgetItem* timeItem = new QTableWidgetItem;
	QTableWidgetItem* processId = new QTableWidgetItem;
	QTableWidgetItem* processName = new QTableWidgetItem;
	QTableWidgetItem* title = new QTableWidgetItem;
	QTableWidgetItem* contentItem = new QTableWidgetItem;

	timeItem->setTextAlignment(Qt::AlignCenter);
	processId->setTextAlignment(Qt::AlignCenter);
	processName->setTextAlignment(Qt::AlignCenter);
	title->setTextAlignment(Qt::AlignCenter);

	timeItem->setText(GetTimeString(time).c_str());
	processId->setText(QString("%1").arg(procId));
	processName->setText(QString::fromStdWString(proc));
	title->setText(QString::fromStdWString(caption));
	contentItem->setText(QString::fromStdWString(content));

	table->AppendRow();
	table->SetAppendRowItem(0, timeItem);
	table->SetAppendRowItem(1, processId);
	table->SetAppendRowItem(2, processName);
	table->SetAppendRowItem(3, title);
	table->SetAppendRowItem(4, contentItem);

	table->RefreshPage();
}
开发者ID:yzx65,项目名称:RemoteControl,代码行数:35,代码来源:useractiondlg.cpp

示例10: creatSearchedItems

void MusicLrcSearchTableWidget::creatSearchedItems(const QString &songname,
                        const QString &artistname, const QString &time)
{
    int count;
    setRowCount(count = m_downLoadManager->getSongIdIndex());

    setStyleSheet(MusicUIObject::MTableWidgetStyle01 + \
                  MusicUIObject::MScrollBarStyle01);

    QTableWidgetItem *item = new QTableWidgetItem;
    item->setData(Qt::DisplayRole, false);
    setItem(count - 1, 0, item);

                      item = new QTableWidgetItem(songname);
    item->setTextColor(QColor(50, 50, 50));
    item->setTextAlignment(Qt::AlignCenter);
    item->setToolTip(songname);
    setItem(count - 1, 1, item);

                      item = new QTableWidgetItem(artistname);
    item->setTextColor(QColor(50, 50, 50));
    item->setTextAlignment(Qt::AlignCenter);
    item->setToolTip(artistname);
    setItem(count - 1, 2, item);

                      item = new QTableWidgetItem(time);
    item->setTextColor(QColor(50, 50, 50));
    item->setTextAlignment(Qt::AlignCenter);
    setItem(count - 1, 3, item);

                      item = new QTableWidgetItem(QIcon(QString::fromUtf8(":/radio/collect")), "");
    item->setTextAlignment(Qt::AlignCenter);
    setItem(count - 1, 4, item);
}
开发者ID:chenpusn,项目名称:Musicplayer,代码行数:34,代码来源:musiclrcsearchtablewidget.cpp

示例11: add

void QEditAssessment::add()
{
    Question q;

    questionList.append(q);

    // Append to question table
    int j = questionTable->rowCount();
    questionTable->insertRow(j);
    //questionTable->setRowHeight(j, 90);

    QTableWidgetItem *item = new QTableWidgetItem(QString::number(j+1));
    item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
    item->setTextAlignment(Qt::AlignHCenter);
    questionTable->setItem(j, 0, item);

    for (int i=1; i<7 ; i++)
    {
        item = new QTableWidgetItem;
        item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);
        item->setTextAlignment(Qt::AlignHCenter);
        item->setBackground(QBrush(QColor(255, 255, 255)));
        questionTable->setItem(j, i, item);
    }
}
开发者ID:pLiuYang,项目名称:Anatomy-Annotator,代码行数:25,代码来源:qeditassessment.cpp

示例12: pushButton_add_clicked

//------------------------------------------------------------
void tke_Form_insert_opSubs::pushButton_add_clicked()
{
	int row = ui.tableWidget_opSubs->rowCount();
	ui.tableWidget_opSubs->setRowCount(row+1);
	QTableWidgetItem * item;
	
	item = new QTableWidgetItem();
	item->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
	ui.tableWidget_opSubs->setItem(row, 0, item);
	
	item = new QTableWidgetItem();
	item->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
	ui.tableWidget_opSubs->setItem(row, 1, item);
	
	item = new QTableWidgetItem();
	item->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
	ui.tableWidget_opSubs->setItem(row, 2, item);
	
	item = new QTableWidgetItem();
	item->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
	ui.tableWidget_opSubs->setItem(row, 3, item);
	
	ui.tableWidget_opSubs->resizeRowToContents(row);
	
	item = ui.tableWidget_opSubs->item(row, 0);
	ui.tableWidget_opSubs->scrollToItem(item);
	ui.tableWidget_opSubs->setCurrentItem(item);
	ui.tableWidget_opSubs->editItem(item);
}
开发者ID:utech,项目名称:tke,代码行数:30,代码来源:tke_Form_insert_opSubs.cpp

示例13: addPlaylistItem

int VideoPlayerWidget::addPlaylistItem(const string &filePath)
{
  // load information about the video file.
  // if libav cannot open the file skip it
  AVFormatContext *formatCtx = NULL;
  if(avformat_open_input(&formatCtx, filePath.c_str(), NULL, NULL) != 0) {
    return -1;
  }
  if(avformat_find_stream_info(formatCtx, NULL)<0) {
    return -1;
  }
  GLdouble numSeconds = formatCtx->duration/(GLdouble)AV_TIME_BASE;
  __CLOSE_INPUT__(formatCtx);

  std::string filename = boost::filesystem::path(filePath).stem().string();
  int row = ui_.playlistTable->rowCount();
  ui_.playlistTable->insertRow(row);

  QTableWidgetItem *fileNameItem = new QTableWidgetItem;
  fileNameItem->setText(filename.c_str());
  fileNameItem->setTextAlignment(Qt::AlignLeft);
  fileNameItem->setData(1, QVariant(filePath.c_str()));
  ui_.playlistTable->setItem(row, 0, fileNameItem);

  QTableWidgetItem *lengthItem = new QTableWidgetItem;
  lengthItem->setText(formatTime(numSeconds));
  lengthItem->setTextAlignment(Qt::AlignLeft);
  lengthItem->setData(1, QVariant(filePath.c_str()));
  ui_.playlistTable->setItem(row, 1, lengthItem);

  return row;
}
开发者ID:daniel86,项目名称:regen,代码行数:32,代码来源:video-player-widget.cpp

示例14: addItem

void PumpSpreadsheet::addItem(const QStringList &fields)
{
    int row = rowCount();
    setRowCount(row + 1);

    QTableWidgetItem *dateItem = new QTableWidgetItem;
    dateItem->setData(Qt::DisplayRole,
                      QDate::fromString(fields[0], Qt::ISODate));
    setItem(row, Date, dateItem);

    QTableWidgetItem *timeItem = new QTableWidgetItem;
    timeItem->setData(Qt::DisplayRole,
                      QTime::fromString(fields[1], Qt::ISODate));
    setItem(row, Time, timeItem);

    QTableWidgetItem *pumpItem = new QTableWidgetItem(fields[2]);
    pumpItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
    setItem(row, Pump, pumpItem);

    QTableWidgetItem *companyItem = new QTableWidgetItem(fields[3]);
    companyItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
    setItem(row, Company, companyItem);

    QTableWidgetItem *userItem = new QTableWidgetItem(fields[4]);
    userItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
    setItem(row, User, userItem);

    QTableWidgetItem *quantityItem = new QTableWidgetItem;
    quantityItem->setData(Qt::DisplayRole, fields[5].toDouble());
    quantityItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
    setItem(row, Quantity, quantityItem);

    QTableWidgetItem *statusItem = new QTableWidgetItem(fields[6]);
    setItem(row, Status, statusItem);
}
开发者ID:HSOFEUP,项目名称:qt5-book-code,代码行数:35,代码来源:pumpspreadsheet.cpp

示例15: replacePlayWidgetRow

void MusicSongsListWidget::replacePlayWidgetRow()
{
    if(m_playRowIndex >= rowCount() || m_playRowIndex < 0)
    {
        m_playRowIndex = 0;
    }
    QString name = !m_musicSongs->isEmpty() ? m_musicSongs->at(m_playRowIndex).getMusicName() : QString();

    setRowHeight(m_playRowIndex, 30);
    removeCellWidget(m_playRowIndex, 0);
    removeCellWidget(m_playRowIndex, 1);
    removeCellWidget(m_playRowIndex, 2);

    delete takeItem(m_playRowIndex, 0);
    delete takeItem(m_playRowIndex, 1);
    delete takeItem(m_playRowIndex, 2);
    QTableWidgetItem *item = new QTableWidgetItem;
    setItem(m_playRowIndex, 0, item);
    item = new QTableWidgetItem(QFontMetrics(font()).elidedText(name, Qt::ElideRight, 242));
    item->setTextColor(QColor(50, 50, 50));
    item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    setItem(m_playRowIndex, 1, item);
    item = new QTableWidgetItem( (*m_musicSongs)[m_playRowIndex].getMusicTime() );
    item->setTextColor(QColor(50, 50, 50));
    item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    setItem(m_playRowIndex, 2, item);
    delete m_musicSongsPlayWidget;
    m_musicSongsPlayWidget = nullptr;
}
开发者ID:karllen,项目名称:TTKMusicplayer,代码行数:29,代码来源:musicsongslistwidget.cpp


注:本文中的QTableWidgetItem::setTextAlignment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。