Qt-----[LSPTrace] 问题

本文详细介绍了如何使用QmlSqlDatabase组件在Qt应用程序中配置并连接到MySQL数据库,包括设置数据库源、名称、用户名、密码、端口及驱动等参数,并提供了组件的完整配置代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.使用MySQL

QmlSqlDatabase{
        id: mainConnection
        connectionName: "myTestSQL"

        // Set the source of the database
        //source: "127.0.0.1"
        source: $Config.getResult("_Mysql_IP")

        // set the database Name
        databaseName: $Config.getResult("_Mysql_Database")

        // set the User of the connection
        user: $Config.getResult("_Mysql_UserName")

        // set the password for that User
        password: $Config.getResult("_Mysql_PassWord")

        // set the port for the connection
        port: $Config.getPort()

        // set the driver to use
        databaseDriver: QmlSqlDatabase.MySql

        // add the database to memory so we can call over and over again
        Component.onCompleted: {
            addDataBase()
        }

        // Run the query to fill the model
        // ! make sure that you are connected first !
        onConnectionOpened: queryModel.exec()
    }

2.出现以下错误

3.修复一下LSP.(CMD管理员模式)

netsh winsock reset

4.当前目录

QString QReadJson::CurrentPath =QDir::currentPath();//并不是exe目录

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值