Đang chuẩn bị liên kết để tải về tài liệu:
The book of qt 4 the art of building qt applications - phần 7

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

Cập nhật cho các tập dữ liệu ngay khi người sử dụng chọn một tập dữ liệu có nghĩa là, một dòng trong xem. SqlTableModel:: OnFieldChange này chuyển mọi thay đổi cơ sở dữ liệu trực tiếp sau khi người dùng đã thay đổi một giá trị trong một lĩnh vực. | 9.7 Using SQL Model Classes with Interview UPDATE for the dataset as soon as the user selects another dataset-that is another row in the view. Sq lTableModel OnFieldChange This transfers every change to the database directly after the user has changed a value in a field. SqlTableModel OnManualSubmit This temporarily saves all changes in the model until either the submitAll slot which transfers all changes to the database or the revertAll slot is triggered. The latter rejects all cached data and restores the status from the database see Chapter 9.7.5 on page 270 for more on the revertAll slot . We will illustrate this last scenario by modifying the example from page 265 so that it additionally contains two buttons that are arranged in a layout beneath the table view. All other commands are left as they are. sqlmvd main.cpp continued QWidget w QPushButton submitPb new QPushButton QObject tr Save Changes QPushButton revertPb new QPushButton QObject tr Roll back changes QGridLayout lay new QGridLayout w QTableView manualTableView new QTableView lay- addWidget manualTableView 0 0 1 2 lay- addWidget submitPb 1 0 lay- addWidget revertPb 1 1 QSqlTableModel manualTableModel manualTableModel.setTable employees manualTableModel.select manualTableModel.setEditStrategy QSqlTableModel OnManualSubmit manualTableView- setModel manualTableModel QObject connect submitPb SIGNAL clicked bool manualTableModel SLOT submitAll QObject connect revertPb SIGNAL clicked bool manualTableModel SLOT revertAll w.setWindowTitle manually revertable table w.show return app.exec After converting the editing strategy to OnManualSubmit we insert two signal slot connections A click on the submitPb button calls the submitAll slot whereas revertPb triggers revertAll . 269 I Ị 9 The QtSql Module Figure 9.5 With the OnManualSubmit editing strategy local changes can be transferred at any time you want to the database. manually revertable table _ n X Id lastname firstname department 1 1 Werner Max 1 2 2 .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.