Results 1 to 8 of 8

Thread: Problem in updating QstandardItemmodel.

  1. #1
    Join Date
    Aug 2014
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Problem in updating QstandardItemmodel.

    I have QStandardItemModel with QCombobox and QTextedit as items. There are three PushButtons selector, next and previous to view the different row items to be selected. But instead of using Push buttons when I select directly the from the drop down menu the text edit is not automatically viewed with correct row item.
    My code is:
    Qt Code:
    1. QStringList detectorMethodLists;
    2. detectorMethodLists << tr("ORB") << tr("SURF") << tr("SIFT") << tr("FAST") << tr("BRISK") << tr("AKAZE");
    3. detectorListModel_ = new QStringListModel(detectorMethodLists, this);
    4. detectorModel_ = new QStandardItemModel(6, 3, this);
    5. QStringList detectorParameterLists;
    6. QString ORBString, SURFString, SIFTString, FASTString, BRISKString, KAZEString;
    7. ORBString = "nFeatures=2000, scaleFactor=1.2, nLevels=8, EdgeThreshold=31, Firstlevel=0, WTA_K=2, ScoreType=0, PatchSize=31";
    8. SURFString = "HessianThreshold=500.00, nOctaves=4, nOctaveLayers=2,extended = true,upright = false";
    9. SIFTString = "nFeatures=0, nOctaveLayers=3, ContrastThreshold=0.04, EdgeThreshold=10.0, Sigma=1.6 ";
    10. FASTString = "Threshold=10, nonmaxSuppression=true, type=TYPE_9_16";
    11. BRISKString = "Thresh=30, Octaves=3, PatternScale=1.0";
    12. KAZEString = " ";
    13. detectorParameterLists << ORBString << SURFString << SIFTString << FASTString << BRISKString << KAZEString;
    14. QStringList detectorTypes;
    15. detectorTypes << "0" << "1" << "2" << "3" << "4" << "5";
    16. for (int detectorRow = 0; detectorRow < 6; ++detectorRow) {
    17. QStandardItem *featureItem = new QStandardItem(detectorTypes[detectorRow]);
    18. detectorModel_->setItem(detectorRow, 0, featureItem);
    19. featureItem = new QStandardItem(detectorParameterLists[detectorRow]);
    20. detectorModel_->setItem(detectorRow, 1, featureItem);
    To copy to clipboard, switch view to plain text mode 
    For example when I directly select(without using PushButton) from ORB to SURF in combobox the textedit string SURFString is not viewed but I view the ORB String.
    Anyone can help me to solve this problem. I think I have to add a code of connecting signal slot.
    Last edited by anda_skoa; 29th August 2014 at 12:14. Reason: missing [code] tags

  2. #2
    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: Problem in updating QstandardItemmodel.

    There are no comboboxes, textedits or pushbuttons anywhere in the code you posted.

    Cheers,
    _

  3. #3
    Join Date
    Aug 2014
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Problem in updating QstandardItemmodel.

    The code of the model is:
    Qt Code:
    1. detectorLabel_->setBuddy(detectorComboBox_);
    2. detectorParameterLabel_->setBuddy(detectorParameterEdit_);
    3. detectorComboBox_->setModel(detectorListModel_);
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 1st September 2014 at 10:25. Reason: missing [code] tags

  4. #4
    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: Problem in updating QstandardItemmodel.

    That should display the entries if detectorListModel_ in detectorComboBox_
    You are saying that this does not work?

    Cheers,
    _

  5. #5
    Join Date
    Aug 2014
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Problem in updating QstandardItemmodel.

    This means that when I directly change ( without using any push button) to SURF from ORB the detectorParameterList which is in the same row as SURF do not change. It shows the detectorParameterList corresponding to ORB combobox.

  6. #6
    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: Problem in updating QstandardItemmodel.

    There is no code in any of your postings that contains changing anything.

    Cheers,
    _

  7. #7
    Join Date
    Aug 2014
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Problem in updating QstandardItemmodel.

    I have not posted the entire code. The code that relates to changing are three push buttons previous button, next button and select button.

    Qt Code:
    1. nextButtonDetector_ = new QPushButton(tr("&Next Detector"));
    2. previousButtonDetector_ = new QPushButton(tr("&Previous Detector"));
    3. selectButtonDetector_ = new QPushButton(tr("&Select Detector"));
    4. The code for updating the view with pushbuttons is:
    5.  
    6. void FeatureDetectorExtractor::updateButtonsDetector(int detectorRow){
    7. previousButtonDetector_->setEnabled(detectorRow > 0);
    8. nextButtonDetector_->setEnabled(detectorRow < detectorModel_->rowCount() - 1);
    9. }
    10. The code related to select button is :
    11. void FeatureDetectorExtractor::selectButtonDetectorClikked(){
    12. QString messageString = tr("The selected Feature Detector is : %1\n Detector parameter : %2\n ").arg(detectorComboBox_->currentText()).arg(detectorParameterEdit_->toPlainText());
    13. QMessageBox msgBox;
    14. msgBox.setWindowTitle("Feature Detector Info");
    15. msgBox.setText(messageString);
    16. msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Retry);
    17. QString detectorType, detectorParameter;
    18. detectorType = detectorComboBox_->currentText();
    19. detectorParameter = detectorParameterEdit_->toPlainText();
    20. int ret = msgBox.exec();
    21. switch (ret) {
    22. case QMessageBox::Ok:
    23. disconnectDetectorButton();
    24. if (detectorType.compare("ORB") == 0){
    25. createORB_detector(detectorParameter); // The function related to ORB
    26. }
    27. else if (detectorType.compare("SURF") == 0){
    28. createSURF_detector(detectorParameter);// related to SURF
    29. }
    30. else if (detectorType.compare("SIFT") == 0){
    31. createSIFT_detector(detectorParameter);
    32. }
    33. else if (detectorType.compare("FAST") == 0){
    34. createFAST_detector(detectorParameter);
    35. }
    36.  
    37. else if (detectorType.compare("BRISK") == 0){
    38. createBRISK_detector(detectorParameter);
    39. }
    40. else{
    41. createKAZE_detector(detectorParameter);
    42. }
    43.  
    44. case QMessageBox::Retry:
    45. break;
    46. }
    47. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 1st September 2014 at 10:25. Reason: missing [code] tags

  8. #8
    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: Problem in updating QstandardItemmodel.

    And again, no code whatsoever related to changing any model or list or combobox.
    Great work!

    Are you making this up as you go along?

    Cheers,
    _

Similar Threads

  1. Replies: 2
    Last Post: 11th February 2012, 00:28
  2. Replies: 2
    Last Post: 7th December 2009, 14:15
  3. Problem with QListWidget Updating
    By flob in forum Qt Programming
    Replies: 2
    Last Post: 21st November 2009, 17:05
  4. QStandardItemModel save/load Problem
    By sun in forum Newbie
    Replies: 9
    Last Post: 1st October 2008, 18:20
  5. Problem with QScrollArea updating from 4.0.1 to 4.1.0
    By SkripT in forum Qt Programming
    Replies: 8
    Last Post: 28th January 2006, 22:35

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.