Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] menuBar() was not declared in this scope. Works for two menus and not for the last one.
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 4.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    ogrishmania
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • O Offline
        O Offline
        ogrishmania
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lgeyer
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved