从数据库实时显示QT c++中的数据
Display data real time in QT c++ from db
像这个一样
该项目有一个具有以下模式的页面:
有一个QlineEdit in integer和一个texBox(或者可以使用另一个小部件(我想在textBox中显示数据库的相关单元格(sqlite带查询,例如:select*frome dbName where code='QlineEdit integer'(,但不需要按钮操作,实时!
当我搜索时,它可以通过textchange((或QLineEdit::editingFinished((实现,但不知道是如何实现的
它的工作原理是这样的,稍后会看到:
connect(ui->nameLine,SIGNAL(textChanged(QString)),this,
SLOT(updateLineEditText(QString)));
void MainWindow::updateLineEditText(QString cd) {
ui->nameLabel->setText("");
QString textEditString(cd);
QString flname;
MainWindow conn;
conn.connopen();
QSqlQuery query;
query.exec("SELECT Firstname, Lastname, Code FROM Election WHERE Code='"+cd+"'");
while (query.next()) {
flname.append( query.value(0).toString() + " ");
flname.append( query.value(1).toString() + " ");
ui->nameLabel->setText(flname);
希望有用;
相关文章:
- 防止主数据类型C++的隐式转换
- 用于访问容器<T>数据成员的正确 API
- 嵌套在类中时无法设置成员数据
- 使用流处理接收到的数据
- 静态数据成员的问题-修复链接错误会导致编译器错误
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- 在cuda线程之间共享大量常量数据
- C++将文本文件中的数据读取到结构数组中
- 如何在C++中序列化结构数据
- 在C++中打印指向不同基元数据类型的指针的内存地址
- 通过套接字[TCP]传输数据 如何在C / C ++中打包多个整数并使用send() recv()传输数据
- 在c代码之间共享数据的最佳方式
- 链表,反向函数,数据结构
- 数据成员SFINAE的C++17测试:gcc vs clang
- C++浮点数据类型和字符串数据类型无法子到模板函数中
- 如何对点云数据进行排序
- 从矢量<无符号字符>转换为字符* 包括垃圾数据
- 尝试通过OCI例程从Oracle获取blob数据,但出现错误:ORA-01008:并非所有变量都绑定
- Cuda C++:设备上的Malloc类,并用来自主机的数据填充它
- 在运行时处理类型擦除的数据-如何不重新发明轮子