Hello there, I've coded a bestiary in C++ that allows users to enter in their own monsters and then access those monsters stats through a database but I am having trouble implementing the search functionality in Qt .
string search;
int stop(0);
getline (cin, search);
ifstream File ("creatures.txt");
if(File.is_open())
{
string line;
int curLine = 0;
while(getline(File, line))
{
curLine++;
if(line.find(search,0)!=string::npos)
{
for(int line_num = 0; line_num = curLine; line_num++)
{
if(getline(File, line) && (line_num == curLine))
{
stop++;
if (stop==16)
break;
cout<<line<< "\n";
}
else
break;
string search;
int stop(0);
getline (cin, search);
ifstream File ("creatures.txt");
if(File.is_open())
{
string line;
int curLine = 0;
while(getline(File, line))
{
curLine++;
if(line.find(search,0)!=string::npos)
{
for(int line_num = 0; line_num = curLine; line_num++)
{
if(getline(File, line) && (line_num == curLine))
{
stop++;
if (stop==16)
break;
cout<<line<< "\n";
}
else
break;
To copy to clipboard, switch view to plain text mode
This code is supposed to allow the user to enter in the name of a monster and then return its stat block and basically i just want the user to do the same thing in Qt except they type the name into a line edit and the stat block appears in another box close by but i cannot figure out what the equivalent code would be to do this in qt so any help would be appreciated.
Bookmarks