Possibilities for adding new **records** inside database
-
Hi
Its a QHeaderView
http://doc.qt.io/qt-5/qheaderview.html
QTableView has one for vert and one for horizontal.
You can use stylesheet or subclass QHeaderView to make it look like like your sample. -
Do we actually talk from the same stuff?
I am not interested neither in any formating stuff nor any visualisations of a star or not.
First thing I need is that a line with fields appear below the HorizontalHeader. The reason is to avoid a lot of QLineEdits Elements.
-
@G4bandit
Well those top and side cells that not editable are controlled by QHeaderView.
So hence i keep talking about it.
Buf look is not important you can ignore it for nowIf you inset empty row in your model it will show there. <if index matches)
user can then fill it out.Since i dont know SSMS im not sure How it does it but it sounded like you want to click on the header at the star cell. then new empty rows comes.
-
@mrjj said in Possibilities for adding new **records** inside database:
Since i dont know SSMS
I just edit the last record. It is shown a Symbol as indice for editing and the data is also checked before saved finally.
IMPORTANT: this is not that table I want to edit inside TableView. Table in pic is for showing the functionality in generall from SSMS.@mrjj said
If you inset empty row in your model it will show there
I do not really know how you mean it but I can not just insert a row because this are 3 tables joined together.
Just thinking: maybe it is at all too hard/difficult to implement such a functionality and I should focus on edit Tbl1 than Tbl2 than Tbl3.
But I still prefer such option like in SSMS is given. -
Hi,
From your description you would need some sort of proxy model that would handle the "virtual row" and and the propagate the new values to each table where it makes sense.
-
@G4bandit said in Possibilities for adding new **records** inside database:
I do not really know how you mean it but I can not just insert a row because this are 3 tables joined together.
Just thinking: maybe it is at all too hard/difficult to implement such a functionality and I should focus on edit Tbl1 than Tbl2 than Tbl3.
But I still prefer such option like in SSMS is given.Still not sure what you mean. If you are creating a
VIEW
byJOIN
ing tables together, you cannot edit rows via theVIEW
(unless it's an editable VIEW, but that's another matter, unless you say that's what you have created), even in SSMS, only view them! You can only edit rows in an actual single table. -
I got very close to the solution here: https://github.com/VSRonin/InsertProxy
For some reason the "virtual" row/column is not editable via the view (but it works programmatically so I suspect it's just something stupid I'm not seeing). I won't be able to work on it to fix it until Monday but you are welcome to have a crack at it.If you solve the problem submit a pull request please
EDIT
Code fixed now
-
@All
Proxy??? Help :O@JonB said in Possibilities for adding new **records** inside database:
Still not sure what you mean. If you are creating a VIEW by JOINing tables together, you cannot edit rows via the VIEW (unless it's an editable VIEW, but that's another matter, unless you say that's what you have created), even in SSMS, only view them! You can only edit rows in an actual single table.
That is correct. I can not edit the rows but like I said it is very uncomfortable to add like 20 LineEdits inside the gui to be able to edit all of my attributes from one table.
So for me is the best solution to desclaim the usage of 20 LineEdits and transfer such input possibility directly inside the QTableView.1.Step
Created a view inside the SSMS with joined table etc whatever completly free. The view is not editable.2.Step Qt
2.1When I press "Insert" than a table pops up with 1...n Attributes, whereas it corresponds to the created view inside SSMS.TblModel->setTable(SSMSView); TblModel->setEditStrategy(QSqlTableModel::OnManualSubmit); TblModel->select(); QSqlRecord record = TblModel->record(); record.setValue(TblModel->fieldIndex("Attribute1"),"*"); record.setValue(TblModel->fieldIndex("Attribute2"),"*"); record.setValue(TblModel->fieldIndex("Attribute3"),"*"); record.setValue(TblModel->fieldIndex("Attribute4"),"*"); TblModel->insertRecord(TblModel->rowCount(),record);
Here a line is created inside the TableView where the mandatory fields are marked with *
Now the user makes his input by inserting data field by field inside the given row.
2.2When I press "Submit" than
...I extract data for table 1 and perform submitAll for the selected table 1.
...I ...table2 ....table2
and so on.Challange solved.