
Originally Posted by
probine
To create a window we can do:
QWidget window;
Can we also do:
This:
QWidget window = new QWindow;
is wrong. With new keyword you have to use a pointer type:
QWidget *window = new QWidget;
To copy to clipboard, switch view to plain text mode
How can we create a window without the NEW keyword?
Normally, like any other objects.
What type of class is it?
hmm it depends what type of object you make:
int a; // this is int
int a; // this is int
QWidget w; // this is QWidget
QListView lv; //this is QListView
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.
Bookmarks