Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. I want add text from textedit to database
Forum Updated to NodeBB v4.3 + New Features

I want add text from textedit to database

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 732 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.
  • T Offline
    T Offline
    trebeter
    wrote on last edited by
    #1

    @
    #include "mainwindow.h"
    #include "ui_mainwindow.h"

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);

    mydb=QSqlDatabase::addDatabase("QSQLITE");
    mydb.setDatabaseName("C:/program1.sqlite");
    
    if(!mydb.open())
        ui->label->setText("Failed");
    else
        ui->label->setText("Open");
    

    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    void MainWindow::on_pushButton_clicked()
    {
    mydb.exec("INSERT INTO personabcd VALUES (null , ??????)");
    }
    @

    i have textedit where i can write something, i'm connected to database, now i want add what i write in textedit to database when i clicked button. What i must do?

    [Edited: Please use code tags "@@" - p3c0]

    1 Reply Last reply
    0
    • D Offline
      D Offline
      David Stiel
      wrote on last edited by
      #2

      Hi,

      I think what you are looking for is : " here":http://doc.qt.io/qt-5/qsqlquery.html#approaches-to-binding-values

      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