0

So I'm currently using the following code in the constructor of my class which has QMainWindow as a base:

char *name = this->windowTitle().toWCharArray;

The codes yields the following error:

error C3867: 'QString::toWCharArray': function call missing argument list; 
use '&QString::toWCharArray' to create a pointer to member

I'm not sure how to proceed so that I can get successfully obtain the window's title.

Martin York
  • 257,169
  • 86
  • 333
  • 562
Elegant
  • 143
  • 2
  • 15
  • Searching on StackOverflow for this error code brings up other questions, including one with [this answer](http://stackoverflow.com/a/9525899/1281433). – Joshua Taylor Oct 02 '13 at 19:16

2 Answers2

6

When you call a function you need to put () at the end:

char *name = this->windowTitle().toWCharArray();
Slava
  • 43,454
  • 1
  • 47
  • 90
0

toWCharArray() is a function. Functions should be called by their name suffixed with (). This is the main rule in C for calling function. Otherwise it shows some exceptions. Call the method suffixed with () as follows:

char *name = this->windowTitle().toWCharArray();

Vidhya Krishnan
  • 169
  • 1
  • 5