PDA

View Full Version : Problem in updating QstandardItemmodel.



urmila
29th August 2014, 10:43
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:


QStringList detectorMethodLists;
detectorMethodLists << tr("ORB") << tr("SURF") << tr("SIFT") << tr("FAST") << tr("BRISK") << tr("AKAZE");
detectorListModel_ = new QStringListModel(detectorMethodLists, this);
detectorModel_ = new QStandardItemModel(6, 3, this);
QStringList detectorParameterLists;
QString ORBString, SURFString, SIFTString, FASTString, BRISKString, KAZEString;
ORBString = "nFeatures=2000, scaleFactor=1.2, nLevels=8, EdgeThreshold=31, Firstlevel=0, WTA_K=2, ScoreType=0, PatchSize=31";
SURFString = "HessianThreshold=500.00, nOctaves=4, nOctaveLayers=2,extended = true,upright = false";
SIFTString = "nFeatures=0, nOctaveLayers=3, ContrastThreshold=0.04, EdgeThreshold=10.0, Sigma=1.6 ";
FASTString = "Threshold=10, nonmaxSuppression=true, type=TYPE_9_16";
BRISKString = "Thresh=30, Octaves=3, PatternScale=1.0";
KAZEString = " ";
detectorParameterLists << ORBString << SURFString << SIFTString << FASTString << BRISKString << KAZEString;
QStringList detectorTypes;
detectorTypes << "0" << "1" << "2" << "3" << "4" << "5";
for (int detectorRow = 0; detectorRow < 6; ++detectorRow) {
QStandardItem *featureItem = new QStandardItem(detectorTypes[detectorRow]);
detectorModel_->setItem(detectorRow, 0, featureItem);
featureItem = new QStandardItem(detectorParameterLists[detectorRow]);
detectorModel_->setItem(detectorRow, 1, featureItem);

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.

anda_skoa
29th August 2014, 12:16
There are no comboboxes, textedits or pushbuttons anywhere in the code you posted.

Cheers,
_

urmila
29th August 2014, 17:49
The code of the model is:

detectorLabel_->setBuddy(detectorComboBox_);
detectorParameterLabel_->setBuddy(detectorParameterEdit_);
detectorComboBox_->setModel(detectorListModel_);

anda_skoa
30th August 2014, 12:56
That should display the entries if detectorListModel_ in detectorComboBox_
You are saying that this does not work?

Cheers,
_

urmila
1st September 2014, 06:56
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.

anda_skoa
1st September 2014, 07:09
There is no code in any of your postings that contains changing anything.

Cheers,
_

urmila
1st September 2014, 10:01
I have not posted the entire code. The code that relates to changing are three push buttons previous button, next button and select button.


nextButtonDetector_ = new QPushButton(tr("&Next Detector"));
previousButtonDetector_ = new QPushButton(tr("&Previous Detector"));
selectButtonDetector_ = new QPushButton(tr("&Select Detector"));
The code for updating the view with pushbuttons is:

void FeatureDetectorExtractor::updateButtonsDetector(in t detectorRow){
previousButtonDetector_->setEnabled(detectorRow > 0);
nextButtonDetector_->setEnabled(detectorRow < detectorModel_->rowCount() - 1);
}
The code related to select button is :
void FeatureDetectorExtractor::selectButtonDetectorClik ked(){
QString messageString = tr("The selected Feature Detector is : %1\n Detector parameter : %2\n ").arg(detectorComboBox_->currentText()).arg(detectorParameterEdit_->toPlainText());
QMessageBox msgBox;
msgBox.setWindowTitle("Feature Detector Info");
msgBox.setText(messageString);
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Retry);
QString detectorType, detectorParameter;
detectorType = detectorComboBox_->currentText();
detectorParameter = detectorParameterEdit_->toPlainText();
int ret = msgBox.exec();
switch (ret) {
case QMessageBox::Ok:
disconnectDetectorButton();
if (detectorType.compare("ORB") == 0){
createORB_detector(detectorParameter); // The function related to ORB
}
else if (detectorType.compare("SURF") == 0){
createSURF_detector(detectorParameter);// related to SURF
}
else if (detectorType.compare("SIFT") == 0){
createSIFT_detector(detectorParameter);
}
else if (detectorType.compare("FAST") == 0){
createFAST_detector(detectorParameter);
}

else if (detectorType.compare("BRISK") == 0){
createBRISK_detector(detectorParameter);
}
else{
createKAZE_detector(detectorParameter);
}

case QMessageBox::Retry:
break;
}
}

anda_skoa
1st September 2014, 17:12
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,
_