[Solved] menuBar() was not declared in this scope. Works for two menus and not for the last one.



  • I've been sitting here for the last hour trying to figure out why it doesn't want to fire(compile).
    Ignore the names(romanian lang).
    Here is the function for the menu:

    @void Telefoane::meniuri()
    {
    meniuGen = new QMenu(tr("&Telefon"), this);
    meniuGen->addAction(cautaAct);
    meniuGen->addAction(inchideAct);
    meniuGen->addSeparator();

    meniuAdmin = new QMenu(tr("&Administrativ"), this);
    meniuAdmin->addSeparator();
    
    meniuDespre = new QMenu(tr("&Help"), this);
    meniuDespre->addAction(despreAct);
    meniuDespre->addAction(despreUact);
    
    
    menuBar()->addMenu(meniuGen);
    menuBar()->addMenu(meniuAdmin);
    menubar()->addMenu(meniuDespre);
    

    }@

    If I comment the last line all works well, if not, it gives me an error there.

    cautaAct, inchideAct, despreAct and despreUact are all QAction pointers declared in the header. They are used in this function:

    @void Telefoane::actiuni()
    {
    cautaAct = new QAction(tr("&Cautare"),this);
    cautaAct->setShortcut(tr("CTRL+C"));
    connect(cautaAct, SIGNAL(triggered()),this, SLOT(showFullScreen()));

    inchideAct = new QAction(tr("&Inchide"),this);
    inchideAct->setShortcut(tr("CTRL+E"));
    connect(inchideAct, SIGNAL(triggered()), this, SLOT(close()));
    
    
    despreAct = new QAction(tr("&About"), this);
    connect( despreAct, SIGNAL(triggered()), this, SLOT(about()));
    
    despreUact = new QAction(tr("About &Qt"), this);
    connect(despreUact, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
    

    }@

    The slots of despreAct and despreUact are for debugging reasons. Normally there are 2 functions with 2 simple QMessageBox that display simple text.

    Edit: I should state that this is my first written app in Qt. If the solution is obvious don't be too harsh.



  • It is <code>menuBar()</code>, not <code>menubar()</code> (notice the capitalized B). C++ is case sensitive.



  • Jesus Christ ... I haven't seen it... I can't believe this :) Thanks a lot!



  • We all have had this now and then, haven't we? ;-)

    You're welcome. Feel free to prepend the initial post title with '[Solved] ...' to indicate that there is already an solution inside.


Log in to reply
 

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