[SOLVED] Invalid use of incomplete type 'class UI::MainWindow'



  • C:\Users\Lorence30\Desktop\test\mainwindow.h:32: error: invalid use of incomplete type 'class Ui::MainWindow' ui->grassyTile
    ^

    why i keep getting this error?

    I have my Q_OBJECT macro inside the MainWindow class.

    *[link text](link url) class MainWindow : public QMainWindow
    {
    Q_OBJECT

    public:
    explic[it MainWindow(QWidget *parent = 0);
    ~MainWindow();](link url)

    private slots:
    void changeTile();
    void pushTile();

    private:
    Ui::MainWindow *ui;
    int counter;

    std::array<Tile,1> tile_list
    {
        ui->grassyTile // heres where error coming from
    };
    

    };


  • Qt Champions 2016

    @Lorence said:

    grassyTile

    What type is that ?

    "use of incomplete type" often means a include file is missing
    or you forwarded a class
    like
    class SomeClass;

    And try to use it in a context where it needs to be fully defined.
    Like adding to some template lists.

    Not sure what you tried to define here ?

    std::array<Tile,1> tile_list <---- ; missing here?
    {
    ui->grassyTile // heres where error coming from
    };



  • grassyTile is of type Tile that is inheriting QLabel

    Not sure what you tried to define here ?
    i dont know how to list intialize an array on constructor so i decided to do it in side a class definition


  • Qt Champions 2016

    @mrjj said:

    and "tile.h" is included ?
    in mainwindow.h

    do you mean like ?
    std::array<std::string, 2> strings = {{ "a", "b" }};



  • and "tile.h" is included ?

    yes i got all i need included.

    do you mean like ?
    std::array<std::string, 2> strings = {{ "a", "b" }};

    yes, in the mainwindow.cpp i can freely use ui->grassyTile; without error.


  • Qt Champions 2016

    @Lorence
    Ok so it must be the tile_list statement.

    Would it like
    std::array<Tile,1> tile_list {{ui->grassyTile }};



  • Would it like
    std::array<Tile,1> tile_list {{ui->grassyTile }};

    thanks for the help but i still get the same error


  • Qt Champions 2016

    @Lorence
    Ok, and you are 100% it knows the tile type here?
    you can declare one over the tile_list and it will like it ?
    Tile *Test;

    One thing I wonder, you say
    std::array<Tile> and not std::array<Tile *) or & so it must make a copy of
    it (the tile). Is that the effect you want?



  • http://i.imgur.com/3O9O6Vg.png
    this is the error im getting


  • Qt Champions 2016

    @Lorence
    Hmm it seems its "ui" it do not like.
    Let me test.


  • Qt Champions 2016

    @mrjj
    ahh, Ui::MainWindow is defined in
    #include "ui_main_window.h"
    which is included in the CPP file so the type is not fully defined so you cannot say
    ui->Somename
    as Ui::MainWindow is not defined yet.

    moving
    #include "ui_main_window.h"
    to the minwin.h file allows it but not sure if it will confuse Qt Creator.

    Also it will complain about not being able to convert Tile to Tile * as list is not pointers and ui->grassyTile will be.



  • ahh, Ui::MainWindow is defined in
    #include "ui_main_window.h"

    didnt think of that, thanks! but new error comes

    http://i.imgur.com/unRPdII.png


  • Qt Champions 2016

    @Lorence

    Yeah, it tries to construct a new Tile to go into the list.

    Can I ask if you want a list of pointers to tiles you have on screen or
    a list with new Tiles that has nothing to do with those on screen?



  • sorry for the late reply.

    i just want a list of tiles to choose from.

    but QT disabled the copying of QLabel,
    so i really need to have a pointer of tiles?


  • Qt Champions 2016

    @Lorence
    heh 9 mins is not considered late ;)

    then the list must be pointer type or it will be new ones and not the ones on screen.

    so
    std::array<Tile> should be std::array<Tile *> or std::array<Tile &>
    so its the ones on screen and not new ones
    Yes you must at least use & as it must "point" to the real one.



  • then the list must be pointer type
    yea, i edited my last reply

    it will be new ones and not the ones on screen.

    it is the ones on the screen, there will be a list of tiles on the screen and the user will choose what tiles they want to render

    *so
    std::array<Tile> should be std::array<Tile > or std::array<Tile &>
    so its the ones on screen and not new ones
    Yes you must at least use & as it must "point" to the real one.

    thanks!!!!!!!!

    all my problem is fixed :) I have not coded for weeks and C++ is already kicking me damit


  • Qt Champions 2016

    @mrjj said:
    ok. Super :)

    and tile_list is the ones to choose from ?

    Dont worry. I programmed c++ for 20 years and it still kicks me ;)



  • and tile_list is the ones to choose from ?

    yes, it is a list of Tile which is inheriting QLabel

    Dont worry. I programmed c++ for 20 years and it still kicks me ;)

    woaaaaa, me is about a year, and started this QT last week, i choose this for my tile engine's interface from SFML, i still have more ways to go !^_^


  • Qt Champions 2016

    @Lorence said:
    welcome on board to Qt. its a nice frame work.

    Oh so its some sort of game editor your are making ?



  • welcome on board to Qt. its a nice frame work.

    Yes my first choice is wxwidget and windows form application, but signals and slots mechanism of qt makes me decide to choose qt

    Oh so its some sort of game editor your are making ?
    yes exatcly, like the rpg maker vx ace of steam


  • Qt Champions 2016

    @Lorence
    Well IMHO Qt is more feature rich than wxwidget even I did like that also.

    Oh. Wow. thats a huge project. !
    So its an editor and and tile engine for making tile games. Pretty cool.



  • Well IMHO Qt is more feature rich than wxwidget even I did like that also.
    yea, in other forum's debation, QT always win, whats IMHO?

    Oh. Wow. thats a huge project. !
    yes this is a huge project for me XD,
    and i still got no idea about integrating script language into this project


  • Qt Champions 2016

    @Lorence
    IMHO = In my humble opinion
    Well I tested both and choose Qt.

    Would also be huge for me to make as single person if we are talking full
    game editor and engine :)

    I would have a good look at http://doc.qt.io/qt-5/qtscript-index.html
    Should be fast enough and quite easy to mix c++ and script.



  • I see

    Im planning to finish this as in 100%

    I would have a good look at http://doc.qt.io/qt-5/qtscript-index.html
    Should be fast enough and quite easy to mix c++ and script.

    thanks!

    We have group on skype do you want to join?


  • Qt Champions 2016

    @Lorence
    ok. to make it a full product? To sell or make games and sell ?

    -- We have group on skype do you want to join?
    Oh thanks for the offer but I only use skype at work as I sit in the living room and
    taking in mics drives the others crazy :)
    So no Team Speak for me either :)

    So you are a group of people making this?



  • ok. to make it a full project ? To sell or make games and sell ?
    I want to sell the whole project. i dont want wasting time doing things that is unrelated to programming so i dont want to make games and sell.

    okay i see np.

    So you are a group of people making this?
    No im the only one making this. the skype group is a group of programmers experts and newbies. just for teaching things


  • Qt Champions 2016

    @Lorence
    Ok, a game maker product.
    You should also consider how to handle support.
    Takes more time than one realizes.

    Ah, that way. Did not know skype has such forums/groups.

    Really good luck with it.



  • yea thanks.

    Ah, that way. Did not know skype has such forums/groups.
    oh no, im really bad at explaining things. i mean
    you can create a conversation group in skype and invite people as many as you can. so i just found this group and then i joined

    okay thanks again :)



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.