Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. View wit 3 column remove row work with 4 column dont work
Forum Updated to NodeBB v4.3 + New Features

View wit 3 column remove row work with 4 column dont work

Scheduled Pinned Locked Moved General and Desktop
4 Posts 1 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pablik2005
    wrote on last edited by
    #1

    Hi
    Table Pracownicy
    [code]
    | Pracownicy | CREATE TABLE Pracownicy (
    IDPracownika int(11) NOT NULL AUTO_INCREMENT,
    IDStanowiska int(11) DEFAULT NULL,
    Imie char(20) NOT NULL,
    Nazwisko char(20) NOT NULL,
    DataUrodzenia date DEFAULT NULL,
    Ulica char(20) DEFAULT NULL,
    NrDomu char(10) DEFAULT NULL,
    KodPocztowy char(5) DEFAULT NULL,
    Miasto char(20) DEFAULT NULL,
    DataZatrudnienia date DEFAULT NULL,
    DataZwolnienia date DEFAULT NULL,
    Pensja float DEFAULT NULL,
    PRIMARY KEY (IDPracownika),
    KEY FK_R1 (IDStanowiska)
    ) ENGINE=MyISAM AUTO_INCREMENT=37 DEFAULT CHARSET=latin1 |
    [/code]

    View
    [code]
    CREATE VIEW V1 AS
    SELECT IDPracownika,Imie,Nazwisko
    FROM Pracownicy

    CREATE VIEW V2 AS
    SELECT IDPracownika,Imie,Nazwisko,IDStanowiska
    FROM Pracownicy
    [/code]

    Now Qt Code
    [code]
    Part 1) //Selecting Table
    Login to DB ....

    QSqlRelationalTableModel model;
    model.setTable("V1");
    model.select();

    QTableView table;
    table.setModel(&model);
    table.show();

    Part 2) //Delete rows
    QModelIndexList t_SelectedRow = table.selectionModel()->selectedRows();
    foreach(QModelIndex i, t_SelectedRow)
    model.removeRow(i.row());
    [/code]

    So, why delete work on V1 but on V2 dont work ??
    In V1 and V2 edit rows work.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Pablik2005
      wrote on last edited by
      #2

      New tip.
      [code]
      CREATE VIEW V3 AS
      SELECT IDPracownika,Imie,Nazwisko,IDStanowiska,DataUrodzenia
      FROM Pracownicy
      [/code]

      For V3 row in model can't edit ???
      Some body can help me ??

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Pablik2005
        wrote on last edited by
        #3

        I have solutnion, i cant remove row if some column is empty (if all column in view have data then i can delete row).
        WHY ????

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Pablik2005
          wrote on last edited by
          #4

          Somebody know, why if columns IDStanowiska or DataUrodzenia is emplt (have Value NULL) then cant delete this row ??
          Columns Imie and Nazwisko can by emplty, because they are NOT NULL and MySQL automatically add empty String .

          Somebody Know how delete row if in View exist column how have NULL value ??

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved