[SOLVED]Displaying an QList<QString>::Iterator inside of a QTextBrowser
-
@SGaist Yes, I want to show the Matching element and then the next 24 elements in the list :)
-
Then you can use the indexOf method to find the position of your text and from there iterate through the rest
-
@SGaist I understand that. I can locate the elements I need to find, I can also display each one individually inside the text browser with out any issues.
My problem is that I'm not able to display every thing inside of the QtextBrowser at the same time like the following
Matched Element
Next Element after matched string
Next Element
Next Element
Next Element
Next Element
I'm not understanding some thing, and I'm sure it's a small over sight thank you for the help you've given me so far I really do appreciate it :)
-
Do you mean add everything at once and not line by line ?
-
@SGaist I need them to display line by line but they all have to be displayed at the same time like this.
-
Name
-
Email Address
-
user name
4 Password
- Description
the user searches for a specific " Listing " by inputing a string that should match " Name " and if it exists, it will display Name and the other four above elements at the same time.
So far I've only managed to get them to show up one at a time, doing this in straight c++ is simple which is why I'm not sure what I'm doing wrong. Consider the following code Snippet as an example of what I'm trying to do!
list<string> MyList; MyList.push_back("Name"); MyList.push_back("Email Address"); MyList.push_back("Username"); MyList.push_back("Password"); MyList.push_back("Description"); string UserInput; std::list<std::string>::iterator iter; std::cout << " Please enter some thing to search for " << std::endl; getline(cin, UserInput); if((iter = std::find(MyList.begin(), MyList.end() , UserInput )) != MyList.end()) { for(int index = 0; index < 5; ++index) { std::cout << *iter << " "; ++iter; } std::cout << std::endl; } //This code snippet would print out " Name Email Address Username Password Description "
This is what I'm trying to do, I can deal with out it being line by line I just can't figure out how to output what I need in the
QtextBrowser Like the above example! -
-
You can build a QStringList then use join to create the output
-
Unfortunately it's still not what I'm looking for ( I could be wrong lol, I'm finding some things are harder to get used to with Qt)
I could be wrong, but join() would basically be the same as prepend right? If so That's not the problem .
ui->textBrowser.setText(" My problem is here, the display its self");
I've used Qts Console output to run various different tests with " Straight C++ " and I get my desired output, I also get it if I use the various qt functions etc.. I just can't get it to display properly in the text browser I may have to switch to some thing else for my display.
Any way thanks for trying I'm going to mark this as solved and I'll just continue to scour the documentation, I'll get it eventually and when I do I'll update this just in-case some one needs to solve the same problem! :)
-
In this case you are wrong, join create one string from your list using the given separator e.g. \n
If that doesn't fit your need, then just generate the complete string that you want to display and only then add it to the QTextBrowser
-
@SGaist At first I wasn't exactly clear on what you meant, but I see now and I agree that did solve my problem! Thank you for all the help and sorry it took so long :)
-
You're welcome !
Don't worry about time ;)
Happy coding !