×

Discussion Board

Results 1 to 11 of 11

Hybrid View

  1. #1
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    72

    How to add Option menus in Mobility Project?

    I have generated a std Mobility Project with a QMainWindow base. Have added code for the menu's

    However clicking the option (left) button in an any of the emulators (Maemo, Symbian Touch/Non-Touch) shows nothing.

    Suggestions?

    Thanks - Lindsay

    Code:
    void MainWindow::setupGeneral()
    {
        deviceInfo = new QSystemDeviceInfo(this);
    
        ui->batteryLevelBar->setValue(deviceInfo->batteryLevel());
    
        connect(deviceInfo, SIGNAL(batteryLevelChanged(int)),
                ui->batteryLevelBar, SLOT(setValue(int)));
    
        // Options Menu
        QAction *actTest1 = new QAction(tr("Test Item 1"), this);
        menuBar()->addAction(actTest1);
        connect(actTest1, SIGNAL(triggered()), this, SLOT(test1()));
    
        QAction *actTest2 = new QAction(tr("Test Item 2"), this);
        menuBar()->addAction(actTest2);
        connect(actTest2, SIGNAL(triggered()), this, SLOT(test1()));
    
    }

  2. #2
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: How to add Option menus in Mobility Project?

    This is how menu is created on Maemo
    http://doc.qt.nokia.com/qt-maemo-4.6/maemo5-menu.html
    In future I suggest you to choose more meaningful thread titles as current one distract people from reading the actual thread.

  3. #3
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    72

    Re: How to add Option menus in Mobility Project?

    Eh?

    1 - How is my title not meaningful?! Its states exactly what I want to know!

    2 - Did you actually read my message? The code snippet I posted does exactly what the one you linked to does. Probably because I searched the forum for examples to try first before asking.

  4. #4
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: How to add Option menus in Mobility Project?

    The title's not meaningful because (A) this has nothing to do with Mobility, and (B) you're dealing with Maemo and should be in the Maemo folder.

    On a separate note, ALWAYS capture and test (with Q_ASSERT) the result from connect(). Can save you hours of debugging time.

  5. #5
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: How to add Option menus in Mobility Project?

    Quote Originally Posted by danhicksbyron View Post
    (B) you're dealing with Maemo and should be in the Maemo folder.
    It was mention of Maemo and Symbian in the original post that's why it was moved from Qt Mobility project to Qt General. I believe there is no significant difference between creation of menus in Maemo and Symbian.

  6. #6
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    72

    Re: How to add Option menus in Mobility Project?

    Nothing to do with mobility? its a mobility project! being tested in the mobility emulators and a real symbian (N95) device. I'm well aware of how menus are added/managed in Qt. The problem is the code for menus I got via the forums is supposed to appear on using the "Select" or "Options" key, but its *doesn't*, not in the Maemo or Symbian emulators or on a real Nokia phone.

    Hence it being a *Mobility* problem. I presuming I'm doing something wrong and I'd appreciate a pointer as to how to attach menus to the select key as I made perfectly clear in my thread title rather than snarky comments.

  7. #7
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: How to add Option menus in Mobility Project?

    It cannot be related to Qt Mobility. There are amount of successful applications using Qt Mobility and having menus. Search in your code for another reason for this behaviour or present us a small test application demonstrating how Qt Mobility can prevent menus from appearing.

  8. #8
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    72

    Re: How to add Option menus in Mobility Project?

    Problem solved mostly.

    Mainly it was because I assumed to much of the symbian emulator - I presumed it would actually emulate the soft key behavour of an actual device, but it doesn't, the menus appear in the qt controller beside it. Additionally unless you add them to a menu bar (which has to be created for QDialog) they won't appear at all.

    Also it took quite a bit of digging to find the QAction::setSoftKeyRole(QAction::PositiveSoftKey); call plus all the examples I could find where for Qt 4.5, QT 4.6 has changed that API considerably.

    Following is a code snippet which works as I wanted - i.e attach menus to the Left and Right soft keys and set the titles for them. Note it takes a conditional compile to work in the emulator plus the emulators doesn't set the soft key titles.

    Code:
    void BatteryIndicator::addSoftKeys()
    {
        ///////////////////////////////////////////////////////
        // Options Menu
        QAction* options = new QAction(tr("Test Select"), this);
    
        QMenu *menuOptions = new QMenu(this);
        menuOptions->addAction(tr("Test 1"), this, SLOT(Test1()));
        menuOptions->addAction(tr("Test 2"), this, SLOT(Test2()));
        options->setMenu(menuOptions);
    
    
        ///////////////////////////////////////////////////////
        // Exit Action
        QAction* exit = new QAction(tr("Test Exit"), this);
        connect(exit, SIGNAL(triggered()), this, SLOT(QuitApp()));
    
        #if defined(Q_OS_SYMBIAN)
            // Set Soft Key locations
            // QAction::PositiveSoftKey = Left Soft Key
            // This will set the left soft key menu
            options->setSoftKeyRole(QAction::PositiveSoftKey);
            exit->setSoftKeyRole(QAction::NegativeSoftKey);
    
            // Add Actions Direct to dialog
            // QAction::NegativeSoftKey = Right Soft Key
            // This will set the right softkey caption and action
            addAction(options);
            addAction(exit);
        #else
            // Create Menu Bar for the QDialog and add to that
            // Note:If you did this under symbian all the menus would be a sub menu of the
            //      Left Soft Key
            QMenuBar *menuBar = new QMenuBar(this);
            layout()->setMenuBar(menuBar);
            menuBar->addAction(options);
            menuBar->addAction(exit);
        #endif
    }

  9. #9
    Registered User
    Join Date
    Mar 2008
    Posts
    33

    Re: How to add Option menus in Mobility Project?

    Hi. I have a same problem. No action in softkey in Qt Simulator.
    I also tried to activate softkey using your code snippet but there is no different.
    Does it only works in the real device?
    Please explain to me more detailedly.

  10. #10
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: How to add Option menus in Mobility Project?

    Yes, softkeys are working properly on real devices and simulator. You are supposed to use Qt 4.6.3 or 4.7 preview.

  11. #11
    Regular Contributor
    Join Date
    Aug 2010
    Posts
    50

    Re: How to add Option menus in Mobility Project?

    As I know, the qt simulator in NokiaQtSDK is bad one. The options and exit are pictures in the simulator, not the real menu . And you can see if the menu appears on the "Applications" tab on the qt simulator WIndow.

Similar Threads

  1. Two Option Menus in the Same View??
    By sandundasa in forum Symbian
    Replies: 4
    Last Post: 2007-10-11, 07:50
  2. how to add more menus to the options softkey in dialog
    By manjunaths in forum Symbian User Interface
    Replies: 0
    Last Post: 2006-12-06, 10:54
  3. My Nokia shows option 'EXIT' on all menus, Why?
    By Jordi Calella in forum Mobile Java General
    Replies: 1
    Last Post: 2005-07-01, 11:13
  4. Replies: 0
    Last Post: 2004-08-06, 04:56

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •