Page 1 of 2 12 LastLast
Results 1 to 20 of 25

Thread: apply change to filtered rows is it possible?

  1. #1
    Join Date
    Mar 2014
    Posts
    25
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question apply change to filtered rows is it possible?

    hi there!

    i am using QSqlRelationalTableModel QSqlTableModel QDataWidgetMapper QSortFilterProxyModel QTableView..
    to filter multiple rows in a column and i use QLineedit to display code of that filtered rows and after filtering i want to change other rows in my second table & my thrid table using tow QComboBox so if i changed content in one of that Combobox it should apply the change to all the rows that have the same code in column( N° 3) whech displaied in QLineEdit.. how to do that is it possible? i am sorry if i can't explain well due to my bad english thanks for help
    Qt Code:
    1. {
    2. ui->setupUi(this);
    3.  
    4. //bla bla bla...
    5. //bla bla bla...
    6.  
    7. myeditModel = new QSqlRelationalTableModel(this);
    8. myeditModel->setTable("myFirstTable");
    9. myeditModel->setRelation(myeditModel->fieldIndex("myFirstForeignKeyID"/*1*/), QSqlRelation("mySecondTable","id","name"));
    10. myeditModel->setRelation(myeditModel->fieldIndex("mySecondForeignKeyID"/*2*/), QSqlRelation("myThirdTable","id","name"));
    11. myeditModel->setRelation(myeditModel->fieldIndex("myCodeID"/*3*/), QSqlRelation("myFourthTable","id","myCode"));
    12. myeditModel->select();
    13.  
    14.  
    15. QSqlTableModel *relationModel1 = myeditModel->relationModel(1);
    16. ui->myFirstComboBox->setModel(relationModel1);
    17. ui->myFirstComboBox->setModelColumn(relationModel1->fieldIndex("name"));
    18.  
    19. QSqlTableModel *relationModel2 = myeditModel->relationModel(2);
    20. ui->mySecondComboBox->setModel(relationModel2);
    21. ui->mySecondComboBox->setModelColumn(relationModel2->fieldIndex("name"));
    22.  
    23.  
    24. mapper = new QDataWidgetMapper(this);
    25.  
    26. mapper->setSubmitPolicy(QDataWidgetMapper::AutoSubmit);
    27. mapper->setModel(myeditModel);
    28. mapper->setItemDelegate(new QSqlRelationalDelegate(this));
    29. mapper->addMapping(ui->myFirstComboBox, 1);
    30. mapper->addMapping(ui->mySecondComboBox, 2);
    31. mapper->addMapping(ui->codeEdit, 3);
    32. mapper->addMapping(ui->dateEdit, 4);
    33.  
    34.  
    35. //bla bla bla...
    36. //bla bla bla...
    37.  
    38.  
    39. mapper->setCurrentIndex(row);
    40.  
    41. QString filterValue = ui->codeEdit->text();
    42.  
    43. myproxy= new QSortFilterProxyModel(this);
    44. myproxy->setSourceModel(myeditModel);
    45. myproxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
    46. myproxy->setFilterRegExp(QRegExp(filterValue, Qt::CaseInsensitive, QRegExp::FixedString));
    47. myproxy->setFilterKeyColumn(/*-1*/3);
    48.  
    49. ui->EditView->setModel(myproxy);
    50. ui->EditView->resizeRowsToContents();
    51. ui->EditView->resizeColumnsToContents();
    52. ui->EditView->setSortingEnabled(true);
    53. ui->EditView->setColumnHidden(0, true);
    54. }
    55.  
    56. myEditDialog::~myEditDialog()
    57. {
    58. delete ui;
    59. }
    60. void myEditDialog::on_codeEdit_selictionChanged(const QString &arg1)
    61. {
    62. myproxy->setFilterFixedString(arg1);
    63.  
    64. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: apply change to filtered rows is it possible?

    I don't see a problem. What have you done so far? How are you updating those two other tables?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    jaafari (3rd April 2015)

  4. #3
    Join Date
    Mar 2014
    Posts
    25
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Thumbs up Re: apply change to filtered rows is it possible?

    thank you !
    thank you !

    i am sorry for my misstakes bro.. i don't update the tow other tables it is a relationshape and i want to update only numbers in rows of column 1 ("myFirstForeignKeyID"/*1*/) and column 2 ("mySecondForeignKeyID"/*2*/) whech is filtered by column 3 ("myCodeID"/*3*/) inside ("myFirstTable") whech i am displaing in my tableview.

    let say LineEdit displaies number (90) and there are 4 rows with the same (90) in column 3 whech are already filtered and column 1 for example displaies 4 rows whech are Foreign Keys and these foreign keys all of theme are number (1) and they displaies the same "name" (name1,name1,name1,name1) also ComboBox1 displaies the same "name" whech is (name1)... now i want to change ComboBox1 to (name9) and this changing should be applied automaticly to those 4 rows so the foreign keys were (1,1,1,1) now should be (9,9,9,9) please look at my diagram and let me now what should i do...
    Attached Images Attached Images

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: apply change to filtered rows is it possible?

    Ok but what is the problem you are having to implement what you wrote here?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #5
    Join Date
    Mar 2014
    Posts
    25
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: apply change to filtered rows is it possible?

    no problem bro

    i just need some help on how combobox apply change to those filtered rows maybe i should write something like this:

    Qt Code:
    1. void EditDlvrDialog::on_myFirstComboBox_somethingChanged(something)
    2. {
    3. something
    4. something
    5. }
    To copy to clipboard, switch view to plain text mode 


  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: apply change to filtered rows is it possible?

    Well, you take the value from the combobox and using that value you update your model. Do you know how to update values from your model?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #7
    Join Date
    Mar 2014
    Posts
    25
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: apply change to filtered rows is it possible?

    no bro i am sorry i don't know


    can you tell me how

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: apply change to filtered rows is it possible?

    You use the QAbstractItemModel::setData() method. In general if you want to use models, you should read about them first.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. The following user says thank you to wysota for this useful post:

    jaafari (3rd April 2015)

  11. #9
    Join Date
    Mar 2014
    Posts
    25
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: apply change to filtered rows is it possible?

    and how to use QAbstractItemModel::setData() ?

  12. #10
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: apply change to filtered rows is it possible?

    Quote Originally Posted by jaafari View Post
    and how to use QAbstractItemModel::setData() ?
    Easy:
    1. you stop being lazy;
    2. you go read the documentation as you were already advised to;
    3. you try to solve your problem;
    4. you come back and explain the approaches you tried, and ask specific questions.

    Does that sound reasonable to you, or would you rather have other people do for free the work you are paid for?

  13. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: apply change to filtered rows is it possible?

    Call it on your model passing the index, value and role in the model you wish to change (e.g. Qt::EditRole).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  14. The following user says thank you to wysota for this useful post:

    jaafari (3rd April 2015)

  15. #12
    Join Date
    Mar 2014
    Posts
    25
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: apply change to filtered rows is it possible?

    Quote Originally Posted by yeye_olive View Post
    Does that sound reasonable to you, or would you rather have other people do for free the work you are paid for?
    i am not a programmer bro.. i am just here to learn and in fact there is no documentation in my language thank you

  16. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: apply change to filtered rows is it possible?

    Quote Originally Posted by jaafari View Post
    i am not a programmer bro.. i am just here to learn and in fact there is no documentation in my language thank you
    There is documentation in English. This forum is English. If you can't understand English documentation, how are you going to understand my English explanation?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  17. The following user says thank you to wysota for this useful post:

    jaafari (3rd April 2015)

  18. #14
    Join Date
    Mar 2014
    Posts
    25
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: apply change to filtered rows is it possible?

    Quote Originally Posted by wysota View Post
    There is documentation in English. This forum is English. If you can't understand English documentation, how are you going to understand my English explanation?
    it is very difficult for me and in some conversation i try translator (thanks to google).. i hope one day other people can find Qt in other languages

  19. #15
    Join Date
    Mar 2014
    Posts
    25
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: apply change to filtered rows is it possible?

    any help guys or should i pay to someone to tell how?

  20. #16
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: apply change to filtered rows is it possible?

    Quote Originally Posted by jaafari View Post
    any help guys or should i pay to someone to tell how?
    What's wrong with the solution already given in comment #11?

    Cheers,
    _

  21. The following user says thank you to anda_skoa for this useful post:

    jaafari (5th April 2015)

  22. #17
    Join Date
    Mar 2014
    Posts
    25
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: apply change to filtered rows is it possible?

    my dear i just want an example even if i will pay for it no problem


    Added after 5 minutes:


    Quote Originally Posted by yeye_olive View Post
    Easy:
    Does that sound reasonable to you, or would you rather have other people do for free the work you are paid for?
    give me a example pravite and i am ready to pay for it.. just tell me how much that will cust?
    Last edited by jaafari; 5th April 2015 at 21:32.

  23. #18
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: apply change to filtered rows is it possible?

    I can give you an example for free.

    Qt Code:
    1. model.setData(model.index(0, 0), 7, Qt::EditRole); // sets 7 into default role of item (0, 0)
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  24. The following user says thank you to wysota for this useful post:

    jaafari (10th July 2015)

  25. #19
    Join Date
    Mar 2014
    Posts
    25
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: apply change to filtered rows is it possible?

    and what about combobox:
    Qt Code:
    1. void myEditDialog::on_myFirstComboBox_currentIndexChanged(int index)
    2. {
    3.  
    4. }
    To copy to clipboard, switch view to plain text mode 

    should i do it like this?

  26. #20
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: apply change to filtered rows is it possible?

    What about it?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 1
    Last Post: 27th September 2012, 23:07
  2. Filter a Filtered QSortFilterProxyModel !?
    By solook in forum Qt Programming
    Replies: 4
    Last Post: 25th October 2011, 20:22
  3. WM_INPUT not being filtered by winEventFilter()
    By been_1990 in forum Qt Programming
    Replies: 1
    Last Post: 12th October 2010, 04:19
  4. QTableView How to change height for all rows?
    By sergey_85 in forum Qt Programming
    Replies: 2
    Last Post: 1st December 2009, 20:49
  5. Replies: 4
    Last Post: 20th September 2007, 14:11

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.