Results 1 to 1 of 1

Thread: How to get textEdit data to work with split regex

  1. #1
    Join Date
    Mar 2017
    Posts
    6
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default How to get textEdit data to work with split regex

    I have a small application that uses sqlite3 to add recipes and then search them by index, name and ingredients.

    The way I've done the ingredients part is

    Qt Code:
    1. ingredients = this->ui->textEdit->toPlainText();
    To copy to clipboard, switch view to plain text mode 

    And then you could query them with

    Qt Code:
    1. ingredients = ui->lineEdit_3-> text() + '%';
    2. ingredients = '%' + ingredients ;
    3.  
    4. QRegExp rx("(\\ |\\,|\\.|\\:|\\t)"); //RegEx for ' ' or ',' or '.' or ':' or '\t'
    5. QStringList ingredients_splt = ingredients.split(rx);
    6.  
    7. this->ui->label->setText(ingredients);
    8.  
    9. QSqlQuery query;
    10.  
    11. if (MainWindow::select_ingredients==1)
    12. {
    13. query.prepare("SELECT ID, name, ingredients FROM recipes WHERE ingredients LIKE (:ingredients)");
    14. .
    15. .
    16. .
    17. query.bindValue(":ID",ID);
    18. query.bindValue(":name",name);
    19. query.bindValue(":ingredients",ingredients_splt);
    20. query.exec();
    21. model->setQuery(query);
    22. }
    To copy to clipboard, switch view to plain text mode 

    But the split won't work. It just skips any regex sepparators.

    I have added my whole project to this post.

    le : I still have some debug coding in my program. Just ignore it.
    Attached Files Attached Files

Similar Threads

  1. Replies: 7
    Last Post: 6th February 2017, 19:10
  2. QByteArray split out data
    By jeffmetal in forum Qt Programming
    Replies: 9
    Last Post: 28th May 2011, 07:24
  3. TextEdit in QDialog not accepting data
    By nbkhwjm in forum Qt Programming
    Replies: 3
    Last Post: 2nd October 2008, 03:53
  4. Replies: 1
    Last Post: 18th December 2006, 10:40
  5. Clearing of data in TextEdit
    By keshab in forum Newbie
    Replies: 3
    Last Post: 15th December 2006, 11:29

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.