×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    18

    QDialog and Softkeys: Problem getting Signals from QActions.

    Heyhey,
    i've got some problems trying to add standard actions to a QDialog. I think my code should be right, but it does not work - indicating my code is not right. Does anybody know what i'm doing wrong?

    I am starting the Dialog by executing exec(). All I want is to exit the dialog by pressing "OK" or "Cancel". I added a QPushButton for exiting - it works. But it's not what I want. I see the buttons, but they do not emit signals - or I am not able to catch them.

    Code:
    //PositionChooser.hpp
    class PositionChooser : public QDialog
    {
    	Q_OBJECT
    private:
    	QWidget* parent;
    	QAction* ok;
    	QAction* cancel;
    	QPushButton p;
    public:
    	Position getPosition() {return Position();/*posWidget.getPosition();*/}
    	PositionChooser(QWidget* parent);
    	void go();
    	~PositionChooser();
    public slots:
    	void stopit();	//test slot
    };
    
    //PositionChooser.cpp
    PositionChooser::PositionChooser(QWidget* parent_) :
    		parent(parent_), p(this)
    {
    	//TODO
    	this->setModal(true);
    
    //does not work
    	ok = new QAction("OK", this);
    	ok->setSoftKeyRole(QAction::PositiveSoftKey);
    	this->addAction(ok);
    	connect(ok, SIGNAL(triggered()), this, SIGNAL(accept()));
    //does not work
    	cancel = new QAction("Cancel", this);
    	cancel->setSoftKeyRole(QAction::NegativeSoftKey);
    	this->addAction(cancel);
    	connect(cancel, SIGNAL(triggered()), this, SIGNAL(reject()));
    	
    //this works
    	p.setText("End");
    	connect(&p, SIGNAL(pressed()), this, SLOT(accept()));
    }
    
    void PositionChooser::stopit()
    {
    //works
    	this->hide();
    	accept();
    	//l.setText((std::string("needs to be implemented.\nCode Line ") + Toolbox::toString<int>(__LINE__, 0)).c_str());
    }
    
    PositionChooser::~PositionChooser()
    {
    	delete ok;
    	delete cancel;
    }
    Any ideas?
    Trying to run stopit() instead of accept() or reject() didn't work, either. Qt Version 4.6.2.

    Thanks in advance,
    Lena
    Last edited by lenalebt; 2010-06-09 at 06:59.

  2. #2
    Super Contributor
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,326

    Re: QDialog and Softkeys: Problem getting Signals from QActions.

    hi,

    Code:
    connect(cancel, SIGNAL(triggered()), this, SIGNAL(reject()));
    In the above line the signal generated by pushbutton is not cached by any slot and it will not work.

    Code:
    connect(&p, SIGNAL(pressed()), this, SLOT(accept()));
    This line generate signal by pushbutton but Due to this and &p it is not cached by the slot.

    See the below article of signal and slot and fix the problem.

    http://wiki.forum.nokia.com/index.ph...Qt_for_Symbian

    Best regards,

  3. #3
    Registered User
    Join Date
    Feb 2010
    Posts
    18

    Re: QDialog and Softkeys: Problem getting Signals from QActions.

    Quote Originally Posted by rahulvala View Post
    hi,

    Code:
    connect(cancel, SIGNAL(triggered()), this, SIGNAL(reject()));
    In the above line the signal generated by pushbutton is not cached by any slot and it will not work.
    It is: This slot is inherited by QDialog. As I said, it works with QPushButton, but not with QAction...

  4. #4
    Super Contributor
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,326

    Re: QDialog and Softkeys: Problem getting Signals from QActions.

    Two signal word inside the connect will not work for you in the QAction..

    Check this article :http://wiki.forum.nokia.com/index.ph...%3F(Qt_for_S60)

    Best regards,

  5. #5
    Registered User
    Join Date
    Feb 2010
    Posts
    18

    Re: QDialog and Softkeys: Problem getting Signals from QActions.

    omg, I must have been blind. Thank you!!

Similar Threads

  1. a problem with softkeys
    By elshorbagy76 in forum [Archived] Flash Lite on Nokia Devices
    Replies: 2
    Last Post: 2009-07-18, 19:12
  2. Problem about softkeys
    By pavan in forum Symbian
    Replies: 2
    Last Post: 2008-09-18, 05:59
  3. softkeys problem
    By ramarao in forum Symbian
    Replies: 7
    Last Post: 2008-01-24, 11:27

Posting Permissions

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