Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML - C++ comunication
Forum Updated to NodeBB v4.3 + New Features

QML - C++ comunication

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 2.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    javiyt
    wrote on last edited by
    #1

    Hi everyone,

    I've just started to develop for Symbian and I downloaded the Qt Creator. It's really helpfull but I'm a beginner in this so I'm really lost.

    I have a couple of questions:

    The first one, I'm trying to make a gradient background generated by C. It's not a big deal but the main problem its that I have to create it indicating the center and the diameter. I would want to make it dynamic depending on the screen size and an element centered I have in the QML. I tried a lot of things searching in the posts but all the answered failed for me. One of them was this one but it doesn't work for me, I guess because I'm not using it correctly.

    @viewer.rootContext()->setContextProperty("mainWindow", this);@

    I tried also trying to get the childs of the QML and get the property with this example but viewer.rootObject is not QObject

    @/*QObject object = viewer.rootObject();
    QObject content = object->findChild<QObject>("content");
    /@

    This is my code:

    @int main(int argc, char *argv[])
    {

    QApplication app(argc, argv);
    
    QRadialGradient radialGrad(175, 200, 400);
    radialGrad.setColorAt(0, QColor::QColor(40,40,40));
    radialGrad.setColorAt(1, Qt::black);
    
    QBrush brush(radialGrad);
    
    QmlApplicationViewer viewer;
    viewer.setBackgroundBrush(brush);
    viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    viewer.setMainQmlFile&#40;QLatin1String("main.qml"&#41;);
    viewer.showExpanded();
    
    return app.exec();
    

    }
    @

    My other question depends also on this QML - C++ Comunication. I would want to minimize the application instead to kill the proccess. I checked that there is a function in QmlApplicationViewer called showMinimize, but should depend on a button in the QML.

    Thank you a lot in advance.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      javiyt
      wrote on last edited by
      #2

      Well just in case someone has the same problem I found the solution.

      Align the radial gradient it's as easy as to get the screen dimensions with:

      @return QApplication::desktop()->screenGeometry();@

      That is a QRect so with that you can get the screen size and then set the background.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved