Skip to content
  • 0 Votes
    13 Posts
    3k Views
    Christian EhrlicherC

    @bartoszpaj said in BindValue() in QPSQL is not working?:

    driver()->hasFeature(QSqlDriver::NamedPlaceholders) returns false.

    Good catch. I think it's because support for PostgreSQL 10 was added in a later version. If the version is not known to the driver it will fall back to the oldest.

  • 0 Votes
    7 Posts
    2k Views
    Pablo J. RoginaP

    @SnuggleKat said in Cannot access MySQL running on another machine:

    Looks like skip-networking solved the problem

    Could you describe what this skip-networking concept is? for the sake of completeness and benefit of documenting the case for other future users having the same issue.

    And if your issue is solved, please don't forget to mark your post as such. Thanks

  • 0 Votes
    6 Posts
    1k Views
    JonBJ

    @Jendker

    A NULL value in a field that is a foreign key can be considered a design flaw of the database.

    When I started to answer your question, that was my initial position (except I wouldn't say "flaw"). When I have used FKs I was never allowed NULL, and I thought that was actually required. However I Googled and plenty said many databases support it (e.g. MySQL) and it was regarded as "acceptable".

    I never did think QSqlRelationalTableModel offered much over QSqlTableModel. It's really just a glorified combobox (model being the FK table) interface in the view. Exactly as 2009 says, a custom delegate could do the job. Just a shame that Qt's doesn't offer NULL handling option for what you want.

  • 0 Votes
    3 Posts
    1k Views
    E

    I'll update this post once I go anywhere with it

    This feedback sounds promising.

    I am becoming more curious around another description for a similar use case:
    An associative table can be created. QStandardItem objects can be generated then based on table entries. Which ways would you like to recommend for the connection of entities to their relationship data?

  • 0 Votes
    8 Posts
    2k Views
    ivandI

    Hi,
    Did you succeed to compile the PostgreSQL plugin for android?

  • 0 Votes
    3 Posts
    825 Views
    SGaistS

    Hi,

    Add a setter to your model that is Q_INVOKABLE and pass your query through it. Don't forget to add proper error checking to give feedback to your user if something goes wrong.

  • 0 Votes
    11 Posts
    2k Views
    E

    Are you looking for an ORM?

    It seems so. - I am used to the technology “object-relational mapping” to some degree.

  • 0 Votes
    11 Posts
    3k Views
    D

    @SGaist Ok that makes sense. Thank you

  • 0 Votes
    3 Posts
    2k Views
    SGaistS

    Hi,

    There’s also no need to allocate the query on the heap as the QSqlQueryModel::setQuery method parameter suggests.

  • 0 Votes
    11 Posts
    2k Views
    VRoninV

    No, bad design. The child should never even know who its parent is.

    The correct process is to push information downstream.

    The child should have setters for all the data it need. The manwindow calls those setters.

  • 0 Votes
    7 Posts
    2k Views
    napajejenunedk0N

    @Christian-Ehrlicher, thanks for the guidance. Marking the topic as solved, since a Qt fix is presumably being awaited. Filed a bug report.

  • 0 Votes
    2 Posts
    811 Views
    SGaistS

    Hi,

    AFAIK, Qt uses default values that one can see in the documentation.

  • 0 Votes
    3 Posts
    1k Views
    E

    @mrjj Many thanks mrjj for your answer. I'll make more researches about SQLite and Taglib.

  • 0 Votes
    11 Posts
    2k Views
    JonBJ

    @G4bandit
    For the filters, only you know what values they might have, I do not. In your table I see a value of 456_45. If you/the user passes that string to search for directly into your function as Filter1 or Filter2 and you generate SQL clause like:
    WHERE Attribute2 LIKE '%"+Filter1+"%'
    so that it expands to
    WHERE Attribute2 LIKE '%456_45%'
    it will not give the result it should do. Up to you whether you wish to deal with this.

    For your compiler error, I have no idea, I don't use C++. All I was suggesting was that you write code to print out/display/whatever string you are passing to your original QM->setQuery(...) statement so that you/we can see what it's actually expanding to. Your compiler error will be to do with it mixing C strings & QStrings. Have a look at, say, https://stackoverflow.com/questions/18427191/how-to-print-string-literal-and-qstring-with-qdebug.

  • QtSql Dataaware cells/boxes

    Unsolved General and Desktop
    6
    0 Votes
    6 Posts
    2k Views
    G4banditG

    @mrjj

    Hey I got it !!! I am gutting better :) unbelivable I solved it this way:

    ui->CB_AdaNr->setModel(TblModel); ui->CB_AdaNr->setModelColumn(TblModel->fieldIndex("Attribute1"));

    And it works.

    Still have the issue that I would like to have dropdowns inside of the QTableView, - the topic at the top.

  • 0 Votes
    14 Posts
    3k Views
    G4banditG

    @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.

  • 0 Votes
    14 Posts
    4k Views
    SGaistS

    Yes that's right. But he can also add the write layer himself like it has been done for QSqlTableModel and others..