相关疑难解决方法(0)

如何连接std :: string和int?

我认为这很简单,但它存在一些困难.如果我有

std::string name = "John";
int age = 21;
Run Code Online (Sandbox Code Playgroud)

如何组合它们以获得单个字符串"John21"

c++ int concatenation stdstring

631
推荐指数
16
解决办法
61万
查看次数

如何连接QStrings?

我在Qt打印有问题.

我在QString变量中有HTML代码.在这段代码中,我想从数据库中插入数据.

我收到一个错误:

E:\apprendreQt\gestionstock6\vente.cpp:117: error: invalid operands of types 
  'const char*' and 'const char [27]' to binary 'operator+'
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?

这是我的代码:

int num_bl = ui->numeroBLlineEdit->text().toInt() ;
QString html;
QString requette = "select num_facture,date,nom,prenom,code_fiscale,designation,qte_out, prix,(qte_out * prix ) as Montant, sum(qte_out * prix) as Total from ventes join produits_en_ventes join clients  join produits on ventes.vente_id = produits_en_ventes.vente_id and ventes.client_id = clients.client_id and produits_en_ventes.produit_id = produits.produit_id where ventes.client_id = :client_id ";

if(!m_db->isOpen())
    QMessageBox::critical(this,tr("Inventoria Solution"),m_db->lastError().text()) ;
else{
    m_query->clear();
    m_query->prepare(requette);
    m_query->bindValue(":client_id ", num_bl);

    if(!m_query->exec())
        QMessageBox::critical(this,tr("Inventoria …
Run Code Online (Sandbox Code Playgroud)

printing qt

14
推荐指数
2
解决办法
7万
查看次数

在QString中连接stl string + int + int + int

可能重复:
使用整数连接两个QStrings

我期待在QT中创建一个3个整数和一个c ++ stl字符串的字符串,我该怎么做?有谁知道?,找不到解释这个过程的东西?

这是我的代码是我在lsit中创建元素,但我想打印所有元素和他们的属性不仅名称:

void Window::listMovies(){
ui->listMovies->clear();
vector <Movie> all = ctrl->getAllMovies();
for(int i=0; i <(int) all.size();i++){
    QListWidgetItem*item = new QListWidgetItem(
                QString::fromStdString(all[i].getName()),ui->listMovies);
    item->setData(Qt::UserRole,QVariant::fromValue(all[i].getID()));
Run Code Online (Sandbox Code Playgroud)

电影对象有1个字符串和3个整数变量.

c++ qstring qt

0
推荐指数
1
解决办法
7128
查看次数

标签 统计

c++ ×2

qt ×2

concatenation ×1

int ×1

printing ×1

qstring ×1

stdstring ×1