Monday, December 27, 2010

Changing the positive & negetive softkeys





Qt menu bar has two menu items, as you would have seen by default left side of the key is “Options” and the right side is “Exit”.
Today we shall see how to change the text of it.
The left key is “Positive Soft key” & the right key is “Negative soft key”. We need to create an action with the positive and negative soft key role and insert to the window, so the keys will get changed.
Ex: For positive soft key:(Left side key)

QAction* Newkey = new QAction("New", this);
Newkey->setSoftKeyRole(QAction::PositiveSoftKey);
this->addAction(Newkey);


Negative soft key: (Right side key)
QAction* close = new QAction("close", this);
close->setSoftKeyRole(QAction::NegativeSoftKey);
this->addAction(close);


Here is the sample code, just put these files in a sample application and run for the results

.cpp file

#include "QT_Softkeys.h"
#include <qmessagebox.h>

QT_Softkeys::QT_Softkeys(QWidget *parent)
    : QMainWindow(parent)
{
        //ui.setupUi(this);
        
    
        QAction* Newkey = new QAction("New", this);
        Newkey->setSoftKeyRole(QAction::PositiveSoftKey);
        this->addAction(Newkey);
        
        QAction* close = new QAction("close", this);
        close->setSoftKeyRole(QAction::NegativeSoftKey);
        connect(close,SIGNAL(triggered()),this,SLOT(closeClickked()));
        this->addAction(close);
                       
        
}

QT_Softkeys::~QT_Softkeys()
{

}

void QT_Softkeys::closeClickked()
        {
        QMessageBox::information(this,"Hi","Hi we r closing");
        QApplication::quit();
        }


Header file

#ifndef QT_SOFTKEYS_H
#define QT_SOFTKEYS_H

#include <QtGui/QMainWindow>
#include "ui_QT_Softkeys.h"

class QT_Softkeys : public QMainWindow
{
    Q_OBJECT

public:
        QT_Softkeys(QWidget *parent = 0);
    ~QT_Softkeys();
    
    public slots:
    void closeClickked();

private:
    Ui::QT_Softkeys ui;
};

#endif // QT_SOFTKEYS_H



6 comments:

  1. Sets of dumbbells can be made use of to tone and educate lots of parts within your entire body.


    my homepage :: Website URL

    ReplyDelete
  2. Together with the tone you are searching for, you might find that you are inside of a marvelous put for convenience with the Bowflex.



    Also visit my webpage bowflex selecttech 552 adjustable dumbbells

    ReplyDelete
  3. On the other hand, in case you have your individual house health club,
    you will be the sole consumer of the conditioning equipments and devices.


    my blog; getfitnstrong.com

    ReplyDelete
  4. So locate the just one you get pleasure from and possess some enjoyable entering into shape.


    Also visit my web blog select dumbbells

    ReplyDelete
  5. Apart from offering your pal an extreme exercise, several of which she can
    define although other folks are preset, this equipment is likewise pretty straightforward to retail outlet and is not going to choose
    up a great deal space.

    Review my weblog :: dumbbell set adjustable

    ReplyDelete
  6. The Powerblock versions possess a pin system to improve the weight of every dumbbell.


    Feel free to surf to my site ... adjustable dumbbells

    ReplyDelete