Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. Independent Developers
  4. I'm trying to create a search box with a widget but I don't know my mistakes
Forum Updated to NodeBB v4.3 + New Features

I'm trying to create a search box with a widget but I don't know my mistakes

Scheduled Pinned Locked Moved Independent Developers
4 Posts 3 Posters 2.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aluco
    wrote on last edited by
    #1

    Hi, here the code:

    @void MainWindow::on_lineEdit_textChanged(const QString &arg1)
    {
    //Descubrir el nombre y la ubicacion del archivo csv
    //QString fileName=QFileDialog::getOpenFileName(this,"Open CSV file",QDir::currentPath(),"CSV (*.csv)");
    //qDebug()<<fileName;
    //colocar el layout
    QVBoxLayout *res_found=new QVBoxLayout(ui->result);
    //abrir archivo
    QFile file("/Users/alfredoluco/Documents/qtExamples/CookIT/bd.csv");
    if(file.open(QIODevice::ReadOnly)){
    QString data=file.readAll();
    QStringList arr=data.split("\n");
    for(int i=0;i<arr.length();i++){
    QStringList vector=arr.at(i).split(";");
    QStringList vector2=vector.at(1).split(".");
    //agregar los ingredientes a el vector correspondiente
    for(int j=0;j<vector2.length();j++){
    ingredientes.append(vector2.at(j));
    }
    }
    //buscar el ingrediente del buscador
    if(checkBoxVector.isEmpty()){
    for(int k=0;k<ingredientes.length();k++){
    checkBoxVector.append(new QCheckBox(ingredientes.at(k)));
    }}
    for(int l=0;l<checkBoxVector.length();l++){
    if(checkBoxVector.at(l)->text().contains(arg1)){
    res_found->addWidget(checkBoxVector.at(l));
    qDebug()<<checkBoxVector.at(l)->text();
    }
    }
    }
    else {
    QVBoxLayout *res_found=new QVBoxLayout(ui->result);
    QLabel *ingred_found=new QLabel();
    ingred_found->setText("<p>No se ha abierto nada!</p>");
    res_found->addWidget(ingred_found);
    ui->result->show();
    }

    delete res_found;
    //delete res_found->layout();
    checkBoxVector.clear();
    ingredientes.clear();
    

    }
    @
    How I can change the cheboxlist in the widget?

    Thanks a lot!

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bladice
      wrote on last edited by
      #2

      Hi, Can you use a correct quotation for you source code, it's very messy.

      Thanks,
      German Zapata Segura

      For some reason, non technical people use to think that every thing with buttons can be fixed by a programmer…

      1 Reply Last reply
      0
      • A Offline
        A Offline
        aluco
        wrote on last edited by
        #3

        Hi,
        I'm updating right now the post.

        Thanks

        1 Reply Last reply
        0
        • D Offline
          D Offline
          Daniel64
          wrote on last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved