Can someone help with resolving this error?
QString *description = new QString;
description = *dialog.descriptionEdit->toPlainText();
error: no match for 'operator*' in '*QTextEdit::toPlainText() const()'
and when I try:
QString *description = new QString;
description = dialog.descriptionEdit->toPlainText();
error: cannot convert 'QString' to 'QString*' in assignment
You need this
*description = dialog.descriptionEdit->toPlainText();
otherwise you are assigning to the pointer not the object it points to. description is a pointer to QString, *description is a QString.
Related
I have a multidimensional string vector, gameState. The contents of gameState can be seen below. I would like to "move" A up one space by making [2][1] = " " and [1][1] = "A". But I'm getting an error (error: invalid conversion from 'const char*' to '__gnu_cxx::__alloc_traitsstd::allocator<char, char>::value_type' {aka 'char'} [-fpermissive]). Not sure if there is a way to use vector.at() in this case. Here is a snippet. The full code reads in the initial game state from a text file and assigns it to the string vector gameState. I get the row and col indexes for each letter in the grid below and assign them to variables (eg. Arow and Acol). I'm very new to C++, so any help would be appreciated. If you have any questions about the rest of the code, I'd be happy to elaborate. Thanks in advance.
int Arow;
int Acol;
vector<string> gameState;
string tempU = gameState[Arow-1][Acol];
if (tempU != "#") {
// if no wall is up, move up
gameState[Arow][Acol] = " ";
gameState[Arow-1][Acol] = "A";
Arow = Arow-1;
Amovesequence.push_back("U");
}
###########
#...#P...B#
#A#.$.###*#
#...#D...R#
###########
The type of gameState[Arow-1][Acol] is a char, not a string. Modify the code accordingly, e.g.: char tempU = ... and replace " " with ' 'etc.
I have the following declaration for a function and I don't know what I am doing wrong with regards to the type declaration:
//function is defined in the OpenCVWrapper.mm file .....no errors
+ (NSArray *)analysePoints:(std::vector<cv::Point> )pointsVector{
.......
}
//error is in the OpenCVWrapper.h file
#interface OpenCVWrapper : NSObject
+ (NSArray *)analysePoints:(NSMutableArray *)mutableArray:(std::vector<cv::Point>)pointsArray;
//red marker under the std
#end
I am getting the error "expecting type" for the vector. What am I doing wrong here?
Actually, I found the solution through user11118321 input to look at the bigger picture. I am using this set up in a swift app that uses openCV through a bridging header. It is actually not possible to import or use a vector in swift.
I just started coding and as I followed Apple's article 'Your Second iOS App:Storyboard', I had a warning that says 'incompatible pointer types initializing Birdsighting *__strong with an expression of type NSString *' from the following code:
detailViewController.sighting = [self.dataController objectInListAtIndex:[self.tableView indexPathForSelectedRow].row];
well you are trying to say (IT SEEMS):
NSString *stringInCurrentTableViewRow = [self.dataController objectInListAtIndex:[self.tableView indexPathForSelectedRow].row];
BirdSighting *yourObject = stringInCurrentTableViewRow;
you are sure the dataController doesnt contain Strings ;)
How to access integer data from a DataTable?
I do this to get a string:
tbEvent.Text = dt.Rows[0].Field<String>(0);
But this doesn't work:
int numb = dt.Rows[0].Field<Int>(0);
Regards,
Tea
int i = Convert.ToInt32(dt.Rows[0]["field_name"]);
Try this :-
tbEvent.Text = dt.Rows[0].Field<Int>(0).ToString();
I'm assuming your trying to pass the value to a Textbox.
Use strongly type access !
if your type is int ,
this
string g = dt.Rows[0].Field<String>(0);
will fail !
Unable to cast object of type 'System.Int32' to type 'System.String'
However if you know its int and you want to show its string represenation : ( or just ToString())
string t= dt.Rows[0].Field<int>(0).ToString();
or just : dt.Rows[0][0].ToString();
The Field extension method does not convert the type appropriate. It just simulates a strongly typed DataTable. So if you know that the type of the DataColumn is int it works this way:
int result = dt.Rows[0].Field<int>(0);
But if it actually comes as string you need to convert/parse it accordingly.
For example:
int result = int.Parse(dt.Rows[0].Field<String>(0));
or even more loosely typed (f.e. because it's a double or you don't know what it is)
int result = int.Parse(dt.Rows[0][0].ToString());
Upon compiling, I am getting the following error:
C:\UDK\UDK-2010-03\Development\Src\FixIt\Classes\ZInteraction.uc(41) : Error, Unrecognized member 'OpenMenu' in class 'GameUISceneClient'
Line 41 is the following:
GetSceneClient().OpenMenu("ZInterface.ZNLGWindow");
But when I search for OpenMenu, I find that it is indeed defined in GameUISceneClient.uc of the UDK:
Line 1507: exec function OpenMenu( string MenuPath, optional int PlayerIndex=INDEX_NONE )
It looks like I have everything correct. So what's wrong? Why can't it find the OpenMenu function?
From the wiki page on Legacy:Exec Function:
Exec Functions are functions that a player or user can execute by typing its name in the console. Basically, they provide a way to define new console commands in UnrealScript code.
Okay, so OpenMenu has been converted to a console command. Great. But still, how do I execute it in code? The page doesn't say!
More searching revealed this odd documentation page, which contains the answer:
Now then, there is also a function
within class Console called 'bool
ConsoleCommand(coerce string s)'. to
call your exec'd function,
'myFunction' from code, you type:
* bool isFunctionThere; //optional
isFunctionThere = ConsoleCommand("myFunction myArgument");
So, I replaced my line with the following:
GetSceneClient().ConsoleCommand("OpenMenu ZInterface.ZNLGWindow");
Now this causes another error which I covered in my other question+answer a few minutes ago. But that's it!
Not sure if this is your intent, but if you are trying to create a UIScene based on an Archetype that has been created in the UI Editor, you want to do something like this:
UIScene openedScene;
UIScene mySceneArchetype;
mySceneArchetype = UIScene'Package.Scene';
GameSceneClient = class'UIRoot'.static.GetSceneClient();
//Open the Scene
if( GameSceneClient != none && MySceneArchetype != none )
{
GameSceneClient.OpenScene(mySceneArchetype,LocalPlayer(PlayerOwner.Player), openedScene);
}