Results 1 to 6 of 6

Thread: Need help asap! Filestream

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2016
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Exclamation Need help asap! Filestream

    Hi! I'm so new to qt and i don't know how to do a filestream. I am creating a login form-filestream based. So i need to create a login form which has of course username and password. First what i did was to use SQLITE as a database and it worked. But the problem is. I have to use filestream that would end up making a new .txt file where the username and passwords would be inputed. I don't know the proper codes to be used in making a filestream from qt and i don't know where in my main code i should put it. i badly need help. The codes that are written there are for sqlite base but i need to change it to a filestream type that would be based from a .txt file. Here's my code:

    Qt Code:
    1. #include "login.h"
    2. #include "ui_login.h"
    3. #include <QMessageBox>
    4. #include <QPixmap>
    5. #include <QFont>
    6. #include <QSplashScreen>
    7. #include <QTimer>
    8.  
    9. Login::Login(QWidget *parent) :
    10. QMainWindow(parent),
    11. ui(new Ui::Login)
    12. {
    13. ui->setupUi(this);
    14. QPixmap pix("C:/Users/Patch/Documents/COE113PROJ/Login/LOGINFORM/images/background.jpg");
    15. ui->background->setPixmap(pix);
    16.  
    17. mydb = QSqlDatabase::addDatabase("QSQLITE");
    18. mydb.setDatabaseName("C:/Users/Patch/Documents/COE113PROJ/Login/LOGINFORM/sqlite/users.db");
    19.  
    20. if(!mydb.open())
    21. ui->status->setText("Failed to open the database");
    22.  
    23. else
    24. ui->status->setText("Connected Succesfuly");
    25. }
    26.  
    27. Login::~Login()
    28. {
    29. delete ui;
    30. }
    31.  
    32. void Login::on_pushButton_login_clicked()
    33. {
    34.  
    35.  
    36. QString name,password;
    37. name=ui->lineEdit_Username->text();
    38. password=ui->lineEdit_Password->text();
    39.  
    40. if(!mydb.isOpen()){
    41.  
    42. qDebug()<<"Failed to open the database";
    43. return;
    44. }
    45.  
    46. QSqlQuery qry;
    47.  
    48. if(qry.exec("select * from users.dbhalp.jpg where name='"+name+"'and password='"+password+"'"))
    49. {
    50. int count=0;
    51. while(qry.next())
    52. {
    53. count++;
    54. }
    55. if(count==1)
    56. {
    57. QMessageBox::information(this,"Login","Username and password is correct ");
    58. hide();
    59. secDiag = new SecDiag(this);
    60. secDiag->show();
    61.  
    62. }
    63.  
    64. if(count>1)
    65. {
    66. QMessageBox::information(this,"Login","Username and password is incorrect");
    67. }
    68. if(count<1)
    69. {
    70. QMessageBox::information(this,"Login","Username and password is incorrect");
    71. }
    72.  
    73.  
    74. }
    75.  
    76.  
    77.  
    78.  
    79. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by anda_skoa; 5th May 2016 at 15:35. Reason: missing [code] tags

Similar Threads

  1. Replies: 1
    Last Post: 20th January 2014, 03:02
  2. problems with usbExample ASAP
    By david_itay in forum Newbie
    Replies: 2
    Last Post: 7th August 2012, 18:52
  3. Asap!!!! Qt duck shoot
    By audrensitas in forum General Discussion
    Replies: 2
    Last Post: 28th April 2011, 11:33
  4. Please help ASAP::QColorDialog
    By LiCodeX in forum Newbie
    Replies: 2
    Last Post: 2nd October 2007, 12:16

Tags for this Thread

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.