maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   [Solved] Help! Can't get QContactManager to work at all (https://talk.maemo.org/showthread.php?t=52165)

eitama 2010-05-08 08:18

[Solved] Help! Can't get QContactManager to work at all
 
Hi,

Edit : I don't really remember what solved this,
But all the code for a working App can be found in the sources of horizontal-call.


I am working on an app for the N900, written in C++/Qt Mobility for PR1.2.

So far, I got a nice GUI running on my phone via Qt + Madde,
and I am stuck trying to make QContactManager to give me what I need. The Qt documentation examples don't work, and I cannot find my way around this problem, been trying for 2 days now.

So the problem is like this : I want to fetch ALL the contacts from the address book, one by one and do some parsing on them,
I am stuck at even accessing the contacts API, I am trying to create a QContactManager object, and I am getting an error accessing it, after including <QContactManager>, I still don't get any autocompletes for it, and it remains out of scope.

Can anyone help me?

Edit : My problem :
http://i880.photobucket.com/albums/a...a/Untitled.png

eitama 2010-05-08 08:23

Re: Help! Can't get QContactManager to work at all
 
And OFC this app goes to garage and repositories when it's done, so please please help me (;

eitama 2010-05-08 10:31

Re: Help! Can't get QContactManager to work at all
 
Bump ):
I am totally stuck, I reinstalled everything, and I am not able to compile most of the examples that come with Qt...

gionni88 2010-05-08 10:40

Re: Help! Can't get QContactManager to work at all
 
I tried to make a radio fm app but got problems with QRadioTuner qtmobility class. It seams not to be working.
On the net I found this page and in the bottom in the platform compatibility it shows almost 0 compatibility with maemo 5...
http://doc.qt.nokia.com/qtmobility-1.0-tp/

aspidites 2010-05-08 10:41

Re: Help! Can't get QContactManager to work at all
 
Mind posting the entire code? Hard to say whats wrong without the full context.

eitama 2010-05-08 10:44

Re: Help! Can't get QContactManager to work at all
 
Quote:

Originally Posted by gionni88 (Post 649134)
I tried to make a radio fm app but got problems with QRadioTuner qtmobility class. It seams not to be working.
On the net I found this page and in the bottom in the platform compatibility it shows almost 0 compatibility with maemo 5...
http://doc.qt.nokia.com/qtmobility-1.0-tp/

Hmmm, thanks for the info! I wonder how old that document is...
But still, it doesn't feel like a compatibility problem.

aspidites 2010-05-08 10:46

Re: Help! Can't get QContactManager to work at all
 
Quote:

Originally Posted by eitama (Post 649137)
Hmmm, thanks for the info! I wonder how old that document is...
But still, it doesn't feel like a compatibility problem.

Dunno, but this is up-to-date.

eitama 2010-05-08 10:48

Re: Help! Can't get QContactManager to work at all
 
Quote:

Originally Posted by aspidites (Post 649135)
Mind posting the entire code? Hard to say whats wrong without the full context.

Sure!

I have written comments to where I have problems,
Right now this compiles just fine, ofc there is a UI file.
If it's needed i'll post it as well.

H File :
Code:

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QGridLayout>
#include <QPushButton>

namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

public slots:
    void callButtonClicked();
    void insertChar();
    void hangUpButtonClicked();

protected:
    void changeEvent(QEvent *e);

private:
    Ui::MainWindow *ui;
    void CreateLetter(QString letter);
    QGridLayout *lettersLayout;
    int row, col;
    QString abc;
    int currentLetter;
    int numberOfLettersPerRow;
    QList<QPushButton*> *existingLetterButtons;
    void init();
    int getNumberOfContacts();

};

#endif // MAINWINDOW_H




CPP File :
Code:

#include "mainwindow.h"
#include "ui_mainwindow.h"
// Something needs to be included to make this work.
// I Don't really know what, but from the help - I can realize that it is : #include <qcontactmanager.h>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    lettersLayout = new QGridLayout();
    lettersLayout->setMargin(0);
    abc = "abcdefghijklmnopqrstuvwxyz";
    numberOfLettersPerRow = 3;
    existingLetterButtons = new QList<QPushButton*>();
    init();
}

int MainWindow::getNumberOfContacts()
{
    // TODO - Here I want to fetch all the number of contacts in the contact list, and itterate through them.
    // I can't get this to compile...
    return 0;
}

void MainWindow::init()
{
    row = col = currentLetter = 0;
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::hangUpButtonClicked()
{
    for (int i = 0; i < existingLetterButtons->size(); i++)
    {
        QPushButton *tempButton = existingLetterButtons->at(i);
        delete tempButton;
    }
    existingLetterButtons->clear();
    init();
}

void MainWindow::changeEvent(QEvent *e)
{
    QMainWindow::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
        ui->retranslateUi(this);
        break;
    default:
        break;
    }
}

void MainWindow::callButtonClicked()
{
    CreateLetter(abc.at(currentLetter));
    if (currentLetter == abc.length() - 1)
    {
        currentLetter = 0;
    } else
    {
        currentLetter++;
    }
}

void MainWindow::insertChar()
{
    QPushButton *tempButton = qobject_cast<QPushButton *>(QObject::sender());
    ui->contactEntry->insert(tempButton->text());
}

void MainWindow::CreateLetter(QString letter)
{
    QPushButton *myButton = new QPushButton();
    myButton->sizePolicy().setVerticalPolicy(QSizePolicy::Minimum);
    myButton->sizePolicy().setHorizontalPolicy(QSizePolicy::Minimum);
    myButton->sizeHint().setHeight(10);
    myButton->sizeHint().setWidth(10);
    existingLetterButtons->insert(existingLetterButtons->size(),myButton);
    myButton->setText(letter);
    connect(myButton, SIGNAL(clicked()), this, SLOT(insertChar()));
    lettersLayout->addWidget(myButton, col, row);
    if (row == numberOfLettersPerRow - 1)
    {
        row = 0;
        col++;
    } else {
        row++;
    }
    ui->lettersFrame->setLayout(lettersLayout);
    myButton->show();
}

Main CPP File :

Code:


#include <QtGui/QApplication>
#include "mainwindow.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;

#if defined(Q_WS_S60)
    w.showMaximized();
#else
    w.show();
#endif
    return a.exec();
}


Joorin 2010-05-08 10:49

Re: Help! Can't get QContactManager to work at all
 
The compiler is your friend. Whatever your IDE reports, the compiler is the one that has to try to use your code. So, compile outside of your IDE and look at the error messages. Then go back to your IDE and fix it.

Most likely, though, is that the path used for includes does not contain the directory where the header file for QContactManager is.

eitama 2010-05-08 10:53

Re: Help! Can't get QContactManager to work at all
 
Quote:

Originally Posted by Joorin (Post 649142)
The compiler is your friend. Whatever your IDE reports, the compiler is the one that has to try to use your code. So, compile outside of your IDE and look at the error messages. Then go back to your IDE and fix it.

Most likely, though, is that the path used for includes does not contain the directory where the header file for QContactManager is.

I am using QTCreator, and it's using qmake I think, I don't know much abount compiling from command line as any other programming I have done was with visual studio (spoiled).
I can build inside QTCreator, and I have to compile output.

How do I check if it is path problems, and fix it?

aspidites 2010-05-08 10:54

Re: Help! Can't get QContactManager to work at all
 
Code:

#include <QContactManager>

eitama 2010-05-08 10:56

Re: Help! Can't get QContactManager to work at all
 
Quote:

Originally Posted by aspidites (Post 649148)
Code:

#include <QContactManager>

I have done that, in the CPP file, If I hover above it with the mouse, it even shows me the correct path to the file.
Then when I try to create an object :

QContactManager *myManager;

there is no "intellisense" or completion, it does not recognize what I am doing.

eitama 2010-05-08 11:00

Re: Help! Can't get QContactManager to work at all
 
I am at the point where I am willing to give whoever is willing to help access via team viewer (; Any takers?

mauricek 2010-05-08 11:08

Re: Help! Can't get QContactManager to work at all
 
Have you added mobility APIs to be used in the .pro file?
Usually the way you do it is:
Code:

CONFIG += mobility
MOBILITY += <your lib to use>


eitama 2010-05-08 11:11

Re: Help! Can't get QContactManager to work at all
 
Quote:

Originally Posted by mauricek (Post 649162)
Have you added mobility APIs to be used in the .pro file?
Usually the way you do it is:
Code:

CONFIG += mobility
MOBILITY += <your lib to use>


From my pro file :

Code:

CONFIG += mobility
MOBILITY =

What exactly should I be writing afert "MOBILITY = " ?

eitama 2010-05-08 12:50

Re: Help! Can't get QContactManager to work at all
 
I have solved my problem.

Was missing this in my CPP :

Quote:

using namespace QtMobility;
SIgh.

Edit : Thanks to all those who tried to help me!

eitama 2010-05-08 14:26

Re: Help! Can't get QContactManager to work at all
 
Well, I maybe solved that problem, but I have a new one!

The N900 returns "memory" as it's available contact manager.
When I query it for contacts, no matter what I do, It returns an empy list.
So I just can't reach the contacts. This is frustrating.

eitama 2010-05-12 17:14

Re: Help! Can't get QContactManager to work at all
 
Bump!

Anyone managed to get contacts using Qt Mobility so far?
If so, I would be thrilled to get some examples!

Kiran.Kumar 2010-09-03 09:33

Re: Help! Can't get QContactManager to work at all
 
Are you still looking for this??

I tried retrieving contacts using Qt mobility and am able to get the list. I run the code with Nokia Qt SDK and got all contacts that are there in simulator. So if you are still looking for this, perhaps, I can help you in this regard .

--
Kiran Kumar

Quote:

Originally Posted by eitama (Post 655454)
Bump!

Anyone managed to get contacts using Qt Mobility so far?
If so, I would be thrilled to get some examples!


eitama 2010-09-03 16:11

Re: Help! Can't get QContactManager to work at all
 
Quote:

Originally Posted by Kiran.Kumar (Post 806048)
Are you still looking for this??

I tried retrieving contacts using Qt mobility and am able to get the list. I run the code with Nokia Qt SDK and got all contacts that are there in simulator. So if you are still looking for this, perhaps, I can help you in this regard .

--
Kiran Kumar

Aye solved it,
Thanks buddy! all the code I used is downloadable from the package page of horizontal-call (in my sig).

It did work in the simulator for me as well, but not on the phone.
I think a release of a newer qtmobility version fixed it eventually.

Tune 2011-02-18 10:46

Re: [Solved] Help! Can't get QContactManager to work at all
 
You have to add this line in the .cpp file

QTM_USE_NAMESPACE

like this:

#include <QContactManager>

QTM_USE_NAMESPACE

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
}


All times are GMT. The time now is 11:04.

vBulletin® Version 3.8.8