Is it possible to get the Item from the tree based upon the text of the item?
Sat My Item (Hello) is inserted into a tree and say after More N number of insertions I want to get the HTREEITEM hItem of Hello item.
I do not want to go to the root and loop as my tree grows very big.
Please help
Related
I currently have a list<float> that are arranged in an increasing order. My sliders min.value is the lowest value of my list (i.e. first element of my list) and sliders max.value is equal to the last item of my list.
What I want to do is that whenever my slider is at a specific value or +-0.1 to one of the elements on my list, I Want to be able to get the index out that specific element to perform a task.
Any suggestions?
Someone asked for code, I don't even like this code since it only gives me the right value once I press "play" from zero, but then it removes my data, so I can't go back with the slider
this code is inside update void, and isPlaying is true when I press a "play" button
if(isPlaying){
timeSlider.value += Time.deltaTime;
timer = timeSlider.value;
print(timeSlider.value);
if((newTimes[0]>=(timer-0.1f)) && (newTimes[0]<=(timer+0.1f))){
print("time: " + newTimes[0]+ " at run time: " + timer);
NewTimes.RemoveAt(0);
}
}
You can set the slider to use whole numbers in the inspector and use the value as your index?
My first thought would be:
Set Slider Steps to Floats in your List
-> Perform task on List[currentSliderStep] as needed
I need to delete a qlistwidget item by text content
I tried:
QString mstring = "Programmer II";
QList<QListWidgetItem *> items = ui->listJobs->findItems(mstring, Qt::MatchExactly);
if (items.size() > 0)
ui->listJobs->takeItem( ui->listJobs->currentRow() );
...and various permutations, but I'm missing something. The code above compiles, but does not delete the item from the qlistwidget.
The code doesn't indicate what the value of currentRow is, but findItems doesn't set it, so it's unlikely to correlate with the value you're trying to remove. I don't see any way to use the results of findItems and get the row(s) you want to remove. I think you have to loop through the contents, compare the text of each item, and then remove the ones that match. You'll probably want to do the loop in reverse order; otherwise, once you've removed an item, the loop counter will no longer match the list item's row numbers.
If I want to change the focus item in the ListView control I do the following:
BOOL setListFocusItem(CListCtrl* pList, int nIndex)
{
return !!pList->SetItemState(nInd, LVIS_FOCUSED, LVIS_FOCUSED);
}
Is this the way you do it?
Because the focus itself changes but there's one issue that this creates. For instance, if the list had 100 items and the focus was on item 1. If I then call my method as such setListFocusItem(99); the focus changes to item 99, but then if I shift-click on item 90, I would expect the list to have items 90 through 99 to be selected. But instead the list selects items 1 through 90. So obviously my setListFocusItem() method does not change the shift-click "first" location. So question is how to make it do it?
Short answer : use the LVM_SETSELECTIONMARK message.
(In MFC-ese, CListCtrl::SetSelectionMark).
I have a List Control in MFC.
With that code:
m_Eintrag3 = m_List.InsertItem(0, _T ("Schaller"));
m_List.SetItemText (m_Eintrag3, 1, _T ("Benedikt"));
m_List.SetItemText (m_Eintrag3, 2, _T ("05.08.1996"));
I can insert an Item and Text in my List Control.
With that code:
if ((m_List.FindItem(&Finde)) != -1)
I can find an Item. But I want to find ItemText. Not just the Item.
Is there any solution? FindItemText doesnt exist.
You have to write your own loop, that checks the Subitems too... FindItem only works on the Item entry. Never on subitems.
I'm trying to parse an Xml file using QDomDocument.
I've got the root element. Now I need to find and extract specfic nodes
under the root element but only at the first level of hierarchy.
I tried to use:
QDomElement root = doc.documentElement();
QDomNodeList nodeList = root.elementsByTagName("apple");
But this returns me a nodeList which contains the nodes with tag Name "apple"
in all levels of hierarchy. But I need only a first level search.
Could someone please help me out.
Thanks
There's no method to do exactly what you want but it's easy to achieve by iterating over the children with something like:
QList<QDomElement> elements;
QDomElement child = root.firstChildElement("apple");
while(!child.isNull()) {
elements.append( child );
child = child.nextSiblingElement("apple");
}