Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Visitor
Posts: 1
Registered: ‎10-08-2012
My Device: non BlackBerry user
My Carrier: Tunisiana
Accepted Solution

signal finished SystemListDialog

#include <bb/system/SystemUiResult>

using namespace bb::cascades;
using namespace bb::system;

namespace bb {
namespace system{
class SystemUiResult;
}
}

Q_INVOKABLE
	void test();
public slots:
    void onPromptFinished(SystemUiResult::Type type);

 

void CarsLogger::test() {
	SystemListDialog *dialog = new SystemListDialog("conf", "canc");
	dialog->setTitle("titre");
	dialog->setSelectionMode(ListSelectionMode::Single);
	dialog->appendItem("item1");
	dialog->appendItem("item2");
	dialog->appendItem("item3");
	dialog->show();

	bool success = QObject::connect(dialog,
			SIGNAL(finished(SystemUiResult::Type)), this,
			SLOT(onPromptFinished(SystemUiResult::Type)));

	if (success) {
		// Signal was successfully connected.
		// Now show the prompt in your UI

		dialog->show();
	} else {
		// Failed to connect to signal.
		dialog->deleteLater();
	}
}

void CarsLogger::onPromptFinished(SystemUiResult::Type type) {
    if (type != SystemUiResult::ConfirmButtonSelection)
        {
        qDebug() << "Prompt Accepted:";
        // The user accepted the prompt.
        }
    else {
        qDebug() << "Prompt Rejected";
        // The user rejected the prompt.
    }
}

 I want to implement a SystemListDialog but i get an error message 

Object::connect: No such signal bb::system:Smiley FrustratedystemListDialog::finished(SystemUiResult::Type) in ../src/CarsLogger.cpp:511

 

does anyone has an example of using SystemListDialog??

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: signal finished SystemListDialog

[ Edited ]

Hi! Use fully-qualified names for signals and slots:

 

SIGNAL(finished(bb::system::SystemUiResult::Type))
SLOT(onPromptFinished(bb::system::SystemUiResult::Type))

p.s. It's not recommended to use "using namespace" in .h files. This will pollute namespace of every .cpp file which includes this header. It's better to use fully-qualified names in .h files and call "using namespace" in .cpp only.

 


Andrey Fidrya, @zmeyc on twitter
Highlighted
New Contributor
Posts: 4
Registered: ‎10-28-2013
My Device: Q5
My Carrier: Blackberry

Re: signal finished SystemListDialog

Hi.

 

I have a similar code, however I have a problem with connect function. That is my code 

 

MessageComposer.hpp

 

#ifndef MESSAGECOMPOSER_HPP_

#define MESSAGECOMPOSER_HPP_

#include "util.hpp"

#include <bb/pim/message/MessageContact>
#include <bb/pim/account/AccountService>
#include <bb/pim/account/Account>
#include <bb/pim/account/Provider>
#include <bb/pim/message/ConversationBuilder>
#include <bb/pim/message/MessageBuilder>
#include <bb/pim/message/MessageService>
#include <bb/pim/message/Attachment>
#include <bb/cascades/Page>
#include <bb/system/SystemListDialog>
#include <bb/system/SystemDialog>

#include <bb/system/SystemToast>

#include <bb/device/HardwareInfo>
#include <bb/platform/PlatformInfo>

namespace bb {
namespace pim {
namespace account {

class MessageComposer {

public:

        Account m_currentAccount;
        bb:Smiley Tongueim::message::MessageContact recipient;
        QString subject;
        bb:Smiley Tongueim::message::Attachment attachment;
        bool hasAttachment;
        QByteArray body;
        QList<bb:Smiley Tongueim::account::Account> m_accountList;
        bb::system:Smiley FrustratedystemListDialog *listdialog;

       

        MessageComposer();
        virtual ~MessageComposer();
        bool selectAccount();
        void getRecipient(QString);
        void getSubject(QString);
        void getAttachment(bool, QString name, QString url);
        void getBody(QString);

       QString addPhoneDatas();
       void updateAccountList();
       void showEmailListDialog();
       void showEmptyEmailList();

       Q_INVOKABLE void sendMessage();

 

public slots:

          void onEmailListFinished(bb::system:Smiley FrustratedystemUiResult::Type type);

};

} /* namespace account */
} /* namespace pim */
} /* namespace bb */
#endif /* MESSAGECOMPOSER_HPP_ */

 

 

MessageComposer.cpp

 

void MessageComposer::showEmailListDialog()
{
           using namespace bb::system;

           listdialog = new SystemListDialog("OK", "Cancel");
           listdialog->clearList();
           listdialog->setTitle("Please, select one of these email accounts");

           foreach (const Account &account, m_accountList) {
                  listdialog->appendItem(account.displayName());
           }

           listdialog->show();

 

           bool success = QObject::connect(listdialog, //bb::system:Smiley FrustratedystemListDialog*&
                                                                SIGNAL(finished(SystemUiResult::Type)), //const char*
                                                                this, //bb:Smiley Tongueim::account::MessageComposer* const
                                                                SLOT(onEmailListFinished(SystemUiResult::Type)));//const char*

           if (success)
                 listdialog->show();
           else
                 listdialog->deleteLater();

 

}

 

void MessageComposer:Smiley SurprisednEmailListFinished(bb::system:Smiley FrustratedystemUiResult::Type type)
{

           using namespace bb::system;

           if (type == SystemUiResult::ConfirmButtonSelection) {
                 qDebug() << "Prompt Accepted:";
                 printf("Button confirm\n"); fflush(stdout);
                 QList<int> index = listdialog->selectedIndices();
                 m_currentAccount = m_accountList.at((index.first() -1));
           } else if (type == SystemUiResult::CancelButtonSelection) {
                 SystemToast *toast = new SystemToast();
                 toast->setBody("If you don't select any account, we can not continue sending the email");
                 toast->show();
           } else
                 qDebug() << "Prompt Rejected";

}

 

 

The error is 

Multiple markers at this line
- no matching function for call to 'QObject::connect(bb::system:Smiley FrustratedystemListDialog*&, const char*, bb:Smiley Tongueim::account::MessageComposer* const,
const char*)'

 

In console:

error: no matching function for call to 'QObject::connect(bb::system:Smiley FrustratedystemListDialog*&, const char*, bb:Smiley Tongueim::account::MessageComposer* const, const char*)'

 

Any idea? All suggestions are welcome, I have spent 1 week  until now and I haven't found the solutions.

 

Thanks, Carmen