How to call main.cpp .cpp files

Hi all

I'm new to c ++.

I have files main.cpp, applicationui.cpp and applicationui.h in the src folder, once I created a new project in the IDE QNX.

In my main.qml, I have a list view to navigate to the page after a clicked (does the qml code).

So, how did I call carousel.cpp (with carousel.h) after that I clicked on the list view.

Any suggestions are welcome.

Thanks in advance.

main.cpp

// Default empty project template
#include 
#include 
#include 
#include 

#include 
#include 
#include "applicationui.hpp"

// include JS Debugger / CS Profiler enabler
// this feature is enabled by default in the debug build only
//#include 

using namespace bb::cascades;

Q_DECL_EXPORT int main(int argc, char **argv)
{
    // this is where the server is started etc
    Application app(argc, argv);

    // localization support
    QTranslator translator;
    QString locale_string = QLocale().name();
    QString filename = QString( "smb_%1" ).arg( locale_string );
    if (translator.load(filename, "app/native/qm")) {
        app.installTranslator( &translator );
    }

    new ApplicationUI(&app);

    // we complete the transaction started in the app constructor and start the client event loop here
    return Application::exec();
    // when loop is exited the Application deletes the scene which deletes all its children (per qt rules for children)
}

applicationui.cpp

// Default empty project template
#include "applicationui.hpp"

#include 
#include 
#include 
#include 
#include 

using namespace bb::cascades;

ApplicationUI::ApplicationUI(bb::cascades::Application *app)
: QObject(app)
{
    // create scene document from main.qml asset
    // set parent to created document to ensure it exists for the whole application lifetime
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);

    if (!qml->hasErrors()) {

            // The application NavigationPane is created from QML.
            NavigationPane *navPane = qml->createRootObject();

            if (navPane) {
                qml->setContextProperty("_navPane", navPane);

                // Set the main scene for the application to the NavigationPane.
                Application::instance()->setScene(navPane);

            }
        }

}

Carousel.cpp

/* Copyright (c) 2012 Research In Motion Limited.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "Carousel.hpp"

#include 
#include 
#include 

#include 

#include 
#include 
#include 
#include 
#include 

#include 

using namespace bb::cascades;

Carousel::Carousel(bb::cascades::Application *app) :
    QObject(app)
{
  qmlRegisterType("utils", 1, 0, "QTimer");
  qmlRegisterType("bb.cascades", 1, 0,
      "QPropertyAnimation");
  // create scene document from main.qml asset
  // set parent to created document to ensure it exists for the whole application lifetime
  QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);

  qml->setContextProperty("app", this);
  // create root object for the UI
  AbstractPane *root = qml->createRootObject();
  // set created root object as a scene
  app->setScene(root);
}

// Getting the byte array of the string
QByteArray Carousel::getBytes(QString str)
{
  return str.toAscii();
}

// We only want the OutCubic easing-curve, try others,  dare you!
QEasingCurve Carousel::getEase()
{
  return QEasingCurve::OutCubic;
}

// This function is needed by the mirroring algo.
static bb::cascades::Image fromQImage(const QImage &origQImage,
    const QImage &mirroredQImage)
{

  bb::ImageData imageData(bb::PixelFormat::RGBA_Premultiplied,
      origQImage.width(), (origQImage.height() * 1.25) + 2);
  int y = 0;

  unsigned char *dstLine = imageData.pixels();

  for (y = 0; y < origQImage.height(); y++)
  {
    unsigned char * dst = dstLine;
    for (int x = 0; x < imageData.width(); x++)
    {
      QRgb srcPixel = origQImage.pixel(x, y);

      *dst++ = qRed(srcPixel) * qAlpha(srcPixel) / 255;
      *dst++ = qGreen(srcPixel) * qAlpha(srcPixel) / 255;
      *dst++ = qBlue(srcPixel) * qAlpha(srcPixel) / 255;
      *dst++ = qAlpha(srcPixel);
    }
    dstLine += imageData.bytesPerLine();
  }

  for (; y < origQImage.height() + 2; y++)
  {
    unsigned char * dst = dstLine;
    for (int x = 0; x < imageData.width(); x++)
    {
      *dst++ = 0;
      *dst++ = 0;
      *dst++ = 0;
      *dst++ = 0;
    }
    dstLine += imageData.bytesPerLine();
  }

  for (; y < imageData.height(); y++)
  {
    unsigned char * dst = dstLine;
    for (int x = 0; x < imageData.width(); x++)
    {
      QRgb srcPixel = mirroredQImage.pixel(x, (y - 2 - origQImage.height()));
      *dst++ = qRed(srcPixel);
      *dst++ = qGreen(srcPixel);
      *dst++ = qBlue(srcPixel);
      *dst++ = qAlpha(srcPixel);

    }
    dstLine += imageData.bytesPerLine();
  }

  return Image(imageData);

}

// Let's not have all the images mirrored, let's do that in code, and some alpha on them aswell
QVariant Carousel::createMirrorImage(QString inputFName)
{

  if (inputFName.isEmpty())
    return QVariant::fromValue(0);

  char buff[1024];
  QString prefix = QString(getcwd(buff, 1024));
  inputFName = prefix + "/app/native/assets/" + inputFName;

  QImage inputQImage(inputFName);
  QImage mirrored_part = inputQImage.mirrored(false, true);
  QPoint start(0, 0);
  QPoint end(0, mirrored_part.height());
  QLinearGradient gradient(start, end);

  gradient.setColorAt(0.0, Qt::gray);
  gradient.setColorAt(0.22, Qt::black);
  gradient.setColorAt(1.0, Qt::black);
  QImage mask = mirrored_part;
  QPainter painter(&mask);
  painter.fillRect(mirrored_part.rect(), gradient);
  painter.end();

  mirrored_part.setAlphaChannel(mask);
  bb::cascades::Image mirrored_image = fromQImage(inputQImage, mirrored_part);
  return QVariant::fromValue(mirrored_image);

}

I think that you have not set the constructor of class carousel with the parameter bb::cascades:Application *.

I think you can call

new Carousel(app);

But the idon't think you create an another qml classroom of carousel, the qml must be loaded in ApplicationUI class only, another class should do the business of your application, but not anything else, should work only in QML

Tags: BlackBerry Developers

Similar Questions

  • How to call sql loader control file with in the pl/sql procedure

    Hi friends,

    I am doing a project in relation to the transfer data using queues. In the queue, I'll get a data delimited by tabs in the form of CLOB variable/message. I don't want to keep this dat in the oracle table.
    During the updating of the data in the table.

    1. don't want to write data to a file. (You want to access directly after the specific queue).

    2. as the data is in the form of delimited by tabs, I want to use sql loader concept.

    How can I call the ctrl charger sql file with in my pl/sql procedure. When I searched, most forums recommending the external procedure or a Java program.

    Please guide me on this issue. My preferrence is pl sql, but don't know the external procedure. If no other way, I'll try Java.

    I'm using oracle 9.2.0.8.0.

    Thanks in advance,
    Vimal...

    Or SQL * Loader, or external tables are designed to read data from a CLOB stored in the database. They both work on files stored on the file system. If you don't want the data to be written to a file, you have to roll your own parsing code. It is certainly possible. But it will be much less effective than SQL * Loader or external tables. And it is likely to lead to a little more code.

    The simplest possible thing that might work would be to use something like Tom Kyte string tokenization package to read a line in the CLOB, divide the component parts and save the different chips in a significant collection (i.e. an object type or a record type that matches the table definition). Of course, you need manage things like the conversion of strings to numbers or dates, rejecting the lines, writing to log files, etc.

    Justin

  • How to call the function lavel root &amp; variable external loaded swf file

    I have little problem in as3.  I load 'mainmenu.swf' file "main.swf". through class loader. so now "main.swf" is children of parents 'mainmenu.swf' file how can call "main.swf" variable and function of "mainmenu.swf".

    The parent of the loaded swf file is the charger.  The main SWF is the parent of the charger.  Then to communicate with the main storyline of the loaded file can use:

    MovieClip (parent.parent) .someFunction ();

  • How to call java xsl?

    Hi all

    My main "OrderCustomerEntry" java class is in the package "Order.Profiles.Customer".

    I have my input xml stored in a String object. Now I stored a xsl in the same package "Order.Profiles.Customer".
    I'm doing some updations to my xml. After that, I have to call a xsl that will finally make a few changes on my xml.

    Kindly tell me how to call this java xsl file.


    Thank you
    Sabarisri. N

    Published by: N Sabarisri October 11, 2011 11:15

    This can be complicated with a lot of factors at play to come. Assume that everything is set up in the right order, if the xsl language is stored in the jar containing the Order.Profiles.Customer package at its root. This means that the pot has a structure as follows:

    Order/Profiles/CustomerOrderCustomerEntry.class
    META-INF/...
    xyz.xsl
    etc
    

    You can try this when it load up.

    String xslFile="xyz.xsl";
    //tf being the factory
    Transformer transformer = tf.newTransformer(new StreamSource(ClassLoader.getSystemResourceAsStream(xslFile)));
    

    Change with regard to the cases where the xslFile is in the current directory is part of the class loader.

    Suppose that it is stored in a directory of resources called "res".

    Order/Profiles/CustomerOrderCustomerEntry.class
    META-INF/...
    res/xyz.xsl
    etc
    

    The corresponding lines would look like this.

    String xslFile="res/xyz.xsl";
    //tf being the factory
    Transformer transformer = tf.newTransformer(new StreamSource(ClassLoader.getSystemResourceAsStream(xslFile)));
    

    I hope this can be enough to you get...

    PS: Although no one should force everyone on the way to name packages, the majority in industry use all lowercase characters when possible.

  • call QML in main.cpp

    Hello

    I want to call a function in main.cpp main.qml!  Is it possible to do this?

    Help me solve this problem!

    Hi Paul24,

    Please check below link

    http://developer.BlackBerry.com/Cascades/documentation/dev/integrating_cpp_qml/index.html

    -------------------------------------------------------------------------------

    feel free to press the button like on the right side to thank the user who has helped you.

  • Weird question has just started - changes in my .cpp file is not used?

    I have a strange problem with my application. I have a working application that I built and submitted for review. I just make some changes and add a feature, but I find that when I change my (as simple as changing the debug messages) .cpp file the application that is deployed on the Simulator is mirror not them. It's just stuck. It works great even after that I have comment lines which should break/change the application.

    Anyone know why/how this could happen? It worked very well there's just before exporting a release build for the presentation of a few days.

    Delete the app in the Simulator? Clean and rebuild the project from scratch?

  • Tried to build and run the "QXmlStreamReader" project, but the display of the device debugging errors] error 2, no rule to make target "main.cpp", need to "debug/main.o.

    I have tried to build and run the project "QXmlStreamReader" with momentics

    but display as errors

    The path location type Resource Description
    make: * [Device-Debug] problem error 2 QXSRExample C/C++
    make [2]: * no rule to make target "main.cpp", need to "debug/main.o.  Stop.    QXSRExample C/C++ problem
    make [1]: * [debug] problem error 2 QXSRExample C/C++

    My project is to

    CBC

    main.cpp

    qxsrexample.cpp

    Inc.

    qxsrexample.h

    assets

    hand. QML etc.

    Reference: http://qt-project.org/doc/qt-4.8/qxmlstreamreader.html

    And

    http://developer.Nokia.com/community/wiki/QXmlStreamReader_to_parse_XML_in_Qt

    I posted a few snippets on the forum some time ago, maybe they are useful:

    https://supportforums.BlackBerry.com/T5/native-development/how-to-parse-XML-data-coming-from-server-...

  • How to call a function within a movieclip on the main timeline in CC animate canvas?

    Hello world...

    In AS3: Function (fnc name: myFunction) inside a Movieclip (mc1). I'll call you timeline mc1.myFunction ();

    But how to call AnimateCC canvas?

    If you have an instance of MovieClip named "mc" with the following code in to:

    This.Fun = function() {}

    Alert ("Hey!");

    }

    You can call this function (increased to 'this' within the MC) using the oon following the main timeline:

    var root = this;

    this.mc.addEventListener ("click", function() {}

    Console.log (root.mc.fun ());

    });

  • How to set up to call a report .rep file to run the report?

    I know that we can attach a RDF report to a form of report.

    But how to call rep report files? I don't want to fix the reports on Forms.

    My name of reports are dynamically from the database.

    I defined my sourceDir under engine element in the rwserver.conf file

    and place the files of my rep under this directory, restart the report server.

    my forms cannot find the report yet.

    It reports an error:

    * "' FRM-41219: can not find the report: invalid ID." * "

    Published by: frank1018 on 8 April 2013 11:51

    There is no difference in calling a file rdf or rep. A rep file is just the compiled version of the rdf.
    If you call your reports with the extension of rdf in the name of the file (myreport.rdf), you have a problem. Just delete the file extension. Now, it won't matter if the file is a file rdf or rep (as long as they are in sourceDir).

    I don't want to fix the reports on Forms.
    My name of reports are dynamically from the database.

    You don't have to join all reports forms. Simply create a report object, without specifying the name of the file. You can do it programmatically:

    v_report_filename := 'Myreport';
    set_report_object_property ( repid, report_filename, v_report_filename); 
    
  • How I 'unmask' main tool bar (i.e. - file, view, tools, etc.)?

    How I 'unmask' main tool bar (i.e. - file, view, tools, etc.)?

    Hello

    Try pressing F9 and let me know if it works.

    ~ Dominique

  • How to call the file of JavaScript in the Page header model

    Hello

    I created a Javascript custom.js file and uploaded in the shared-> component static files.
    How to call this file in the Header of Page Template, I mean the exact syntex...

    Thank you
    Deepak

    Hello

    File name must be typed exactly the same as the file that you downloaded.

    Are you sure that your file is OK? Did you remove

    wwv_flow_file_mgr.get_file?p_security_group_id=4967074027259628303&p_fname=custom.js
    
  • How to call adobe pdf reader to open the PDF files in your application BB10?

    Hi all

    Can anyone please write an example of cascades showing how to call adobe pdf reader to open PDFs inside my BB10 stunts application?

    Thanks,.

    Mohanad

    This is how to do it:

    https://developer.BlackBerry.com/Cascades/documentation/device_platform/invocation/AdobeReader.html

  • How to call a value of preference in the XSLT file

    Hi all

    How to call a value preference (which is defined in bpel already) in the XSLT?

    Can someone help me please

    Kind regards

    Villeneuve ch

    Get the value of preference and and check out the post below to pass as a parameter

    http://www.albinsblog.com/2012/07/passing-parameter-to-XSLT-in-SOA-11g.html#.UjfqfMZmiSo

    Concerning

    Albin I

  • How to call the file MXML of LinkBar

    Hello
    I want to create a link bar. I want to put 3 buttons in there to call 3 different mxml files.

    Any advice?

    Thank you

    I did it by URLRequest :)

    Simple

    Thank you all.

  • How to call the function cascade BlackBerry

    I begineer in blackberry c ++.

    I do two class is testobject and second in test .i call the onther text function average () and nexttext();

    so please how to call this function.

    // Default empty project template
    #include "TestObect.hpp"
    
    #include 
    #include 
    #include 
    
    using namespace bb::cascades;
    
    TestObect::TestObect(bb::cascades::Application *app)
    : QObject(app)
    {
        // create scene document from main.qml asset
        // set parent to created document to ensure it exists for the whole application lifetime
        QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    
        // create root object for the UI
        AbstractPane *root = qml->createRootObject();
    
        // set created root object as a scene
        app->setScene(root);
    }
    
    void TestObect::test(){
    
        qDebug()<< "****************Naveen";
    }
    

    I insert also declared in the header file.

    Q_INVOKABLE Sub test();

    then I create another test class.

    /*
     * test.cpp
     *
     *  Created on: Apr 2, 2013
     *      Author: nksharma
     */
    
    #include "test.h"
    
    test::test() {
        // TODO Auto-generated constructor stub
    
    }
    
    void test:: nexttest(){
        qDebug()<<"***********Next test*********"
    
    }
    test::~test() {
        // TODO Auto-generated destructor stub
    }
    

    error in the file namespace,

    here in file herder

    the namespace error

    /*
     * test.h
     *
     *  Created on: Apr 2, 2013
     *      Author: nksharma
     */
    
    #ifndef TEST_H_
    #define TEST_H_
    
    class test {
    public:
        test();
        virtual ~test();
         Q_INVOKABLE void nexttest();
    };
    
    #endif /* TEST_H_ */
    

    You have a space between the colon and the n in:

    void test:: nexttest()
    

    Another thiing, if you are using Q_INVOKABLE, you must declare Q_OBJECT in your front header file public:

     


    If you're still having problems, try to clean up the project with Project > clean...

Maybe you are looking for