Skip to content
Qt 6.11 is out! See what's new in the release blog
  • 145k Topics
    725k Posts
    S
    Well, maybe a small side quest: The easiest method to make the algorithm parallel might be using OpenMP: long dividend = ...; // the number to test for primality long limit = sqrt(test); bool isPrime = false; #pragma omp parallel for shared(limit,dividend,divisor,isPrime) for (long divisor = 2; divisor <= limit; divisor++) if (dividend % divisor == 0) isPrime = true; return isPrime; You have to turn on OpenMP (something like -fopenmp) to make it run in parallel. OpenMP automatically scales with the number of cores and you can even choose a scheduling algorithm and chunk size to optimize it further. Quick testing can be done by setting OpenMP environment variables to change the defaults. The equivalent in Qt is actually QtConcurrent. QtConcurrent::run doesn't really help because most of the work is still on your shoulders, but map-and-reduce is perfect for this. QtConcurrent actually starts a thread pool and does not oversubscribe your CPU cores (even with QtConcurrent::run). It is also not constantly starting new threads, but reuses threads from the thread pool. You can do similar things with QThread if you just start the event loop for each worker thread and push "tasks" by using QMetaObject::invokeMethod. You might have noticed that for the OpenMP example I did not include early termination (yet). IIRC with OpenMP this is a little bit more complicated and you might have to write continue to run empty loops for "early terminations". Usually (independent of OpenMP), it is sufficient to have a boolean variable accessible to all threads and let one thread toggle it if it finds a solution. It does not have to be atomic. For early termination you probably don't care if termination is immediate or slightly delayed (until the cores have synched up). At least, you don't have to pay for the overhead of an atomic in every single loop iteration. If you are looking for a fast solution, you can get some inspiration from Dave Plummer's Prime Drag Race. Dave Plummer is a retired Microsoft engineer on YouTube. In the Prime Drag Race people competed/compete with different programming languages to write the fastest program.
  • Jobs, project showcases, announcements - anything that isn't directly development
    4k 23k
    4k Topics
    23k Posts
    SGaistS
    @yungys said in Looking for Desktop Engineer (Electron, TS, React) for Private Client: @hskoglund That’s a fair point. By “lightweight,” I mean the application itself — a compact desktop client with a focused feature set and minimal resource overhead, rather than a claim about the technology stack. Electron, TypeScript, and React are simply the technologies we’re planning to use. Then my question stands: in what way is this job offer related to Qt ?
  • Everything related to designing and design tools

    133 402
    133 Topics
    402 Posts
    A
    Thanks a lot for all this information. It has helped me get clarity on the questions that have been bugging me for weeks. I can now decide better what I want to do, and why. I will definitely share these with them ideas about unifying the UI for mobile and desktop with Qt, as it seems like it doesn't necessarily warrant replacing starting their application from scratch, only their UI code will get replaced (and its bindings).
  • Everything related to the Software Quality Tools

    96 267
    96 Topics
    267 Posts
    Arsh129A
    Classic off-by-one and coordinate offset traps! Mixing up button bitmasks (like 4 vs 1) and missing container bounds will throw off any automation instantly. Good catches tracking those down.
  • Everything related to learning Qt.

    401 2k
    401 Topics
    2k Posts
    Nils SjobergN
    Nice..now he knew whether to perform certification
  • 2k Topics
    13k Posts
    SGaistS
    Please check with the Gerrit admins if that is doable.
  • 4k Topics
    18k Posts
    S
    可以换个账号试试
  • This is where all the posts related to the Qt web services go. Including severe sillyness.
    1k 10k
    1k Topics
    10k Posts
    M
    I had the same “You are not authorized” error when trying to create a Jira ticket. AlexBlasche’s fix works perfectly, use the direct login URL first