News

Develop for the Nokia N900 and Maemo 5 OS!

Learn how to program the next-generation smartphone-come-internet tablet, the Nokia N900…

Nokia_N900

Initial file to open inside the editor:

QFile file(“moc_codeColor.cpp”);
if (file.open(QFile::ReadOnly | QFile::Text))
editor->setPlainText(file.readAll());
}
void MainWindow::setupFileMenu()
{
QMenu *fileMenu = new QMenu(tr(“&File”), this);
menuBar()->addMenu(fileMenu);

Connect signals and slots:

fileMenu->addAction(tr(“&New”), this, SLOT(newFile()),
QKeySequence(tr(“Ctrl+N”,
“File|New”)));
fileMenu->addAction(tr(“&Open…”), this, SLOT(openFile()),
QKeySequence(tr(“Ctrl+O”,
“File|Open”)));
fileMenu->addAction(tr(“E&xit”), qApp, SLOT(quit()),
QKeySequence(tr(“Ctrl+Q”,
“File|Exit”)));
}
void MainWindow::setupHelpMenu()
{
QMenu *helpMenu = new QMenu(tr(“&Help”), this);
menuBar()->addMenu(helpMenu);
helpMenu->addAction(tr(“&About”), this, SLOT(about()));
helpMenu->addAction(tr(“About &Qt”), qApp, SLOT(aboutQt()));
}

8. Creating the project file
You can either use qmake to create the project file or write it by hand. It is recommended that you use qmake first and then customise it according to your needs. For our simple project , a qmake-generated project file is enough.

Open the Scratchbox environment and perform the following command to create the project file.

[sbox-FREMANTLE_X86: ~/codeEditor] > qmake -project
This command will generate a project file with the directory name. In this case it is codeEditor.pro
codeEditor.pro
##################
# Automatically generated by qmake (2.01a) Thu Jan 12 12:30:01 2010
##################

TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .

# Input
HEADERS += codeColor.h mainwindow.h
SOURCES += codeColor.cpp main.cpp mainwindow.cpp

9. Generating the makefile and compiling the application
Makefiles specify how to derive the target program from each of its dependencies. Now that we have the project file with us, we can use qmake to generate the Maemo-specific makefile.
Open the Scratchbox environment and perform the following command to create the makefile:

[sbox-FREMANTLE_X86: ~/codeEditor] > qmake

×