To create a window we can do:
QWidget window;
Can we also do:
QWidget window = new QWindow;
How can we create a window without the NEW keyword? What type of class is it?
To create a window we can do:
QWidget window;
Can we also do:
QWidget window = new QWindow;
How can we create a window without the NEW keyword? What type of class is it?
Ahh... you can create one if you read a introduction into C++!!! Come on, that is so basic stuff!Qt Code:
To copy to clipboard, switch view to plain text mode
This:
is wrong. With new keyword you have to use a pointer type:QWidget window = new QWindow;
Qt Code:
To copy to clipboard, switch view to plain text mode
Normally, like any other objects.How can we create a window without the NEW keyword?
hmm it depends what type of object you make:What type of class is it?
Qt Code:To copy to clipboard, switch view to plain text mode
Generally, widgets should be created on a heap (so with new keyword) but in main() function it is good to create main widget on stack so it will be deleted when going out of scope which is when your application exit.
I would like to be a "Guru"
Useful hints (try them before asking):
- Use Qt Assistant
- Search the forum
If you haven't found solution yet then create new topic with smart question.
Thanks for the answers. And even though it seems basic, the question is much more complex. Pretend:
_____
class Person
{
...
// Anything that a class will have goes here
}
_____
To instantiate this class I must do:
Person myPerson = new Person();
I couldn't do:
Person myPerson;
Base on this example does it mean that QWidget is a regular class, a struct or what?
I would like to be a "Guru"
Useful hints (try them before asking):
- Use Qt Assistant
- Search the forum
If you haven't found solution yet then create new topic with smart question.
Bookmarks