Skip to content
  • 0 Votes
    5 Posts
    337 Views
    T

    Thank you all ! I think @JonB 's suggestion will do the job since my goal is more comprehensive.

  • Help with QWidget::show()

    Solved General and Desktop
    17
    0 Votes
    17 Posts
    3k Views
    JonBJ

    @mmikeinsantarosa
    Indeed, that is how Qt documentation lays out its methods.

    To reiterate something @Christian-Ehrlicher said. In Qt nomenclature:

    Methods ending in Event (showEvent(), mouseMoveEvent()) are not signals. Instead they are protected virtual methods. You must sub-class and override if you want to access them.

    Signals tend to be named as the past tense of something that has happened (clicked(), customContextMenuRequested()). You cannot override them. You can connect() to them, without needing to sub-class.

    And slots are just named as an action to be performed (show(), setDiabled()).

  • 0 Votes
    3 Posts
    390 Views
    N

    @SGaist Thanks for the offer of looking over a code sample. I have found that by setting W to be a Qt::Popup rather than a Qt::Window, this solves my problem.

  • 0 Votes
    10 Posts
    6k Views
    F

    @jsulm I tried. But it cannot be closed as there is nothing to close ( there is no dialog/application in the first place). Haha. its alright. I will continue to explore and see if there is any other way.

  • 0 Votes
    31 Posts
    15k Views
    T

    @kshegunov said in Function after setupUi():

    Probably flooding the main thread's event loop.

    Okey I optimized a code little bit:

    QtConcurrent::run([=]() { int i; int value; double dResult = 1; for(i = 0;i < 20000000;i++) { dResult = qExp(qCos(qTan(qSin(qPow(qSqrt(((((i * 1337) / 7) * 73) * 1329) % 1937),7) * dResult)) / qAsin(qPow(qSin(dResult * i * qTan(1337 * i)), 29)))); if((i % 200000) == 0) { value = i / 200000; emit showResult(QString::number(dResult)); emit pBarSetValue(value); } } emit showResult(QString::number(dResult)); emit pBarSetValue(100); });

    It tooks few seconds for my CPU, but yea UI is responsible and progressbar is changing in realtime

    Problem was because

    emit showResult(QString::number(dResult)); emit pBarSetValue(i);

    runs 5000000 times

    I don't follow. Add a stop signal where? You run a function imperatively with the proposed QtConcurent::run (as C++ is an imperative language), you can't just break in the middle of it ...

    I dont know, maybe that Quit Application signal will tell to OS scheduler that scheduler has to kill worker thread

    So only disadvantage of that method is that I cannot stop worker thread in middle of operation?

    //EDIT, thanks for help :)

  • 0 Votes
    3 Posts
    2k Views
    J

    Hi SGaist and thank for the help.

    For the code being in the constructor when it should not be, I only did it that way to have the simplest code possible to show my issue. I understand and agree with your point. I am working on an already existing application, I created this QtCreator project to isolate and replicate the issue. I do not call QWidget::show() in the constructor of my application.

    I have made an important discovery while working on this issue: calling blue_widget->show() at the end of my code in my QtCreator project does fixe the problem, but doing the same in my application does not fix the issue. This is the 1st time I see a different behavior, I thought I had manage to have the same 1:1 behavior between the QtCreator project and my application.

    Thanks for the help, I will keep looking.

  • 0 Votes
    4 Posts
    1k Views
    Joel BodenmannJ

    In that case I won't be able to help, sorry.

    You can see that there's a Show Recent Blog Posts checkbox on the left side. That's something that none of the QtCreator versions I use have. Looking at the recent blog posts shown in that screenshot it seems like the QtCreator version is somewhere <= 3.3.0. So either this feature got removed in the more recent versions (4.0.2 is the current one) or it's a Mac OS X only feature (which I highly doubt).
    I'm sure that somebody can shed light on this.

    You would definitely have better changes of getting an answer to this if you post it in the correct forum. Maybe a moderator can move it.

  • 0 Votes
    3 Posts
    1k Views
    mrjjM

    Hi
    QStackedwidget is also good for a design where you want a mainwindow
    with "pages"

  • 1 Votes
    9 Posts
    3k Views
    niqtN

    @bogong For me it's normal develop qt (also for mobile application), but in this time I must develop a strange case, I must use a native controller (that it can't be emulate in qt/qml) and from this I must start the qml GUI. It's all ok, I see the qml elements but I can't catch the user interaction, not press button, nothing. I started from Qt project where I added native object-c files, AppDelegate, other native controller, etc.

  • 0 Votes
    7 Posts
    2k Views
    stackprogramerS

    @SGaist @vlada
    thanks
    finally i built for apk android it works.....
    it's image
    image test svg for android
    goodluck

  • 0 Votes
    5 Posts
    19k Views
    R

    @Chris-Kawa said:

    QThread docs

    Oh!! Then I need to make a worker class and do something like:

    thread = new QThread(); thread->start(); worker = new Worker; worker->moveToThread(thread); // this is the initialization of a QWizardPage in the QWizard WizardPageClass1 *page1 = new WizardPageClass1 ; page1->setWorker(worker);

    And then where I have the lengthy operation, emit a signal (DoOperation for example) and in its constructor make a connect like connect(this, DoOperation(), worker, doWork()) if doWork() is where I have the lenghty operation with?

  • 0 Votes
    11 Posts
    3k Views
    artwawA

    @Cosford
    I am happy to hear you made it.

    If I helped in any way - my pleasure.