default argument error
-
hi
what is AvailableTile ?
Seems it has a constructor that wants two arguments instead of the normal parent only.ui_mainwindow is generated from the UI file by a program called moc.
If you edit it, your modifications will be gone next time it is regenerated.
Its far better to change stuff outside the file ,
like in mainwindows constructor
after
ui->setupUi ( this );You can access any widget with ui->
so anything you can do in ui_mainwindow you can do here and it is not overwritten. -
In fact you must put the default arguments from right to left. To solve your problem you must write :
AvailableTile(QString img_path, QWidget* parent = 0); -
what is AvailableTile ?
AvailableTile is a constuctor from AvailableTile class.AvailableTile(QWidget* parent = 0);
this default constructor doesnt have any problem.
**
You can access any widget with ui->
so anything you can do in ui_mainwindow you can do here and it is not overwritten**.
grass = new AvailableTile(centralWidget); // this is the generated code of ui_mainwindow
but i need it to be
grass = new AvailableTile("../Desktop/grass.png",centralWidget);so how do i do that
-
Perhaps AvailableTile has a function to set img_path after it has been constructed with the
default constructor ?If not, you must create yourself and insert into the mainwindow.
You cannot get Creator to use the other constructor via the UI generator.is AvailableTile your own class?