GithubHelp home page GithubHelp logo

Debugging console about qtfirebase HOT 9 CLOSED

Trikos avatar Trikos commented on July 28, 2024
Debugging console

from qtfirebase.

Comments (9)

Larpon avatar Larpon commented on July 28, 2024

Hi @Trikos
I'm glad to hear you got it working 🙂
I think you're referring to this ?

from qtfirebase.

Trikos avatar Trikos commented on July 28, 2024

Yes but you do you get the data inside the console? Im trying to print the qDebug from the C++ code inside this console. How do I achieve this? I think that if I write something I will be overwritten everytime

from qtfirebase.

Larpon avatar Larpon commented on July 28, 2024

It's done in the App QML singleton.
If you want to include qDebug messages from C++ I guess you could just set a message handler in C++ that redirects messages to a similar QML singleton or something?

from qtfirebase.

Trikos avatar Trikos commented on July 28, 2024

I don't know how to implement this handler. Right now I'm appending text into a QString and emitting a signal every time it gets updated, but it is a very bad implementation xD

from qtfirebase.

Larpon avatar Larpon commented on July 28, 2024

I can' t help with any specific setups. I have this code in one of my projects:

void messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
    QByteArray localMsg = msg.toLocal8Bit();
    const char *file = context.file ? context.file : "";
    const char *function = context.function ? context.function : "";
    switch (type) {
    case QtDebugMsg:
        //fprintf(stderr, "Debug (%s:%u) %s: %s\n", file, context.line, function, localMsg.constData());
        break;
    case QtInfoMsg:
        fprintf(stderr, "Info (%s:%u) %s: %s\n", file, context.line, function, localMsg.constData() );
        break;
    case QtWarningMsg:
        //fprintf(stderr, "Warning (%s:%u) %s: %s\n", file, context.line, function, localMsg.constData());
        break;
    case QtCriticalMsg:
        fprintf(stderr, "Critical (%s:%u) %s: %s\n", file, context.line, function, localMsg.constData());
        break;
    case QtFatalMsg:
        fprintf(stderr, "Fatal (%s:%u) %s: %s\n", file, context.line, function, localMsg.constData());
        break;
    }

}

int main(int argc, char *argv[])
{
   qInstallMessageHandler(messageOutput);

   ... <rest of your main.cpp> ...
}

So instead of using fprintf as I do in this example - you'd send a QString off to your QML object instead.

from qtfirebase.

Trikos avatar Trikos commented on July 28, 2024

What do you mean by "send a QString off to your QML"? I would replace fprintf with MyClass.MyQString = context.line.
Or you are referring to my main QML object that it is always a QQuickView?
`QQuickView *view = new QQuickView;

MyClass clss;

view->rootContext()->setContextProperty("MyClass", &clss);
view->setSource(QUrl("qrc:/Init.qml"));
view->setResizeMode(QQuickView::SizeRootObjectToView);
view->show();

return app.exec();`

Thank you, appreciate your master explanation and help

from qtfirebase.

Larpon avatar Larpon commented on July 28, 2024

Whatever works I guess.

You could probably send messages via a SingletonInstance also - there's many ways to do it I think.

If the way you're doing it currently, works - I guess there's no need to fix it 😉

from qtfirebase.

Trikos avatar Trikos commented on July 28, 2024

Ok, perfect and thanks again

from qtfirebase.

Larpon avatar Larpon commented on July 28, 2024

@Trikos I'm glad to help 🙂

from qtfirebase.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.