Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.5k Topics 456.8k Posts
  • How to propagate/limit stylesheets through code

    Solved 7 Jun 2020, 17:09
    0 Votes
    5 Posts
    780 Views
    5 years later, I've stumbled on the solution for Option 2. What I was doing wrong was not calling unpolish() and polish() methods. The correct order is call unpolish(), setstylesheet(), and polish(). Now the styles are applied correctly on all child widgets.
  • Trying to load a frame of widgets using a shared pointer

    Unsolved 25 days ago
    0 Votes
    5 Posts
    151 Views
    Pointers in Qt look naked, but they are not. As said before widgets own all their child widgets and handle them being cleaned up. And certainly there is a place in C++ for non-owning raw pointers. Don't use shared_ptr in every single place. If you call a function it is okay if it expects a raw pointer while you have the shared_ptr. If you start copying the shared_ptr into every function you call you will loose a lot of performance. Sure, you can use a const std::shared_ptr & instead, but that is also defeating the purpose and no different than raw pointers. Raw pointers are not evil, but owning raw pointers are. In your tiny example the raw pointer is owning for just a very short time (most likely only for the the two lines if there is nothing in between). If you want to be pedantic you could follow the approach of @IgKh and use a std::unique_ptr. But, it is most certainly mandatory to use std::make_unique to create the object. Otherwise allocation might still fail and throw an exception and the unique_ptr does not become the owner and the destructor of partially created objects (if you are using inheritance) are not called. You see from this that just using smart pointers does not always solve the problem because you can still use them wrong if you don't understand everything about them. And there is very little gain in your specific case in using a smart pointer (correctly). And for most programs it is true that they don't catch out-of-memory errors and handle them properly to free up some memory. I would personally never use smart pointers with Qt widget types. (Unless Qt in new versions rewrites their library to make them mandatory.)
  • license

    Unsolved 26 days ago
    0 Votes
    6 Posts
    199 Views
    @IgKh said in license: As long as you do so in the confines of your company, which you should clear with the legal department. Well, if he develops it as a hobby in his own spare time isn't using it inside the company distributing it? To be pedantic: Yes, you need a license (that's how the law works). However, there are open source licenses for Qt ;-) It is perfectly fine to use Qt under the LGPL for commercial projects and even sell your own software using Qt with this license. Just because your project is commercial doesn't mean you need a commercial license (unless it is embedded software???). If you want to use Qt under the LGPL you need to be careful that you don't use some of the very few modules (like Qt Charts) that are only available under the GPL or commercial license. If you are using modules under the GPL you need to make your own source code available under the GPL. Once your source code is under the GPL you don't have much control over who can use your software. Anybody in your company can give the software (including the source code) to anybody else and you cannot prevent them if your own source code is under the GPL. Most likely this won't happen, but it is explicitly allowed by the GPL.
  • Setting QT application .exe icon

    Solved 23 days ago
    0 Votes
    3 Posts
    104 Views
    @hskoglund said in Setting QT application .exe icon: Unfortunately it has fared rather badly in the conversion from qmake to CMake, it compiles and runs fine but without any app icon or details (in contrast to the qmake-based version from Qt 5) I was able to reproduce the error. I realized I missed an important step in the documentation for setting the app icon in CMAKE: If you do not use qmake, the necessary steps are: first, create an .rc file and run the rc or windres program on the .rc file, then link your application with the resulting .res file. Works with target_sources(MyApp PRIVATE ${app_icon_resource_windows })
  • How to set colors for LineSeries in QtGraphs using C++

    Solved 29 days ago
    0 Votes
    2 Posts
    105 Views
    It's my falut. I have mentioned the author of the raw code , too. [image: 747ae764-4b2f-46da-a33e-29d762645cc2.png] QList<QPointF> data should be cleared at each time.
  • Issue with Qt6 QML Module Target Path and CMake Warning

    Unsolved 23 days ago
    0 Votes
    1 Posts
    78 Views
    No one has replied
  • 0 Votes
    2 Posts
    83 Views
    There are a few open bug reports that might be relevant. https://bugreports.qt.io/browse/QTBUG-130316 https://bugreports.qt.io/browse/QTBUG-97930
  • QListWidget with checkboxes - checking more than one row at a time

    Unsolved 25 days ago
    0 Votes
    14 Posts
    318 Views
    @Jackmill said in QListWidget with checkboxes - checking more than one row at a time: @jeremy_k said in QListWidget with checkboxes - checking more than one row at a time: A flag or list of indexes to be modified could accomplish the same goal while leaving view management intact. How might I do this? I'm having trouble thinking of a way to call setData without causing an endless loop. void onDataChanged(const QModelIndex topLeft, const QModelIndex bottomRight, const QList<int> &roles) { static bool updating = false; if (roles.contains(ItemDataRole::CheckStateRole) && !updating) { updating = true; auto value = topLeft.data(ItemDataRole::CheckStateRole); for (auto index : selectionModel.selectedIndexes()) model->setData(index, ItemDataRole::CheckStateRole, value); updating = false; } } The code could also disconnect this (and only this) slot from the signal prior to the loop, and reconnect it at the end.
  • Install third party shared libraries with QT's cmake deployment API

    Unsolved 25 days ago
    0 Votes
    1 Posts
    43 Views
    No one has replied
  • qt unit test build error: The "XmlPeek" task failed unexpectedly

    Unsolved 26 days ago
    0 Votes
    2 Posts
    75 Views
    Hi, Does your test contain any actual code ? If so, try to empty it to see if it is still failing.
  • How C++ 20 Setup for Qt creator ?

    Solved 25 days ago
    0 Votes
    3 Posts
    95 Views
    @cristian-adam Thanks, it works. Sorry I am new to all this.
  • Qt6 CMake qt_add_resources with LANG why does order matter ?

    Unsolved 29 days ago
    0 Votes
    5 Posts
    186 Views
    @SGaist Yes of course, I've put a minimal compilable project to reproduce the issue on github: qt_cmake_localized_resources_issue
  • This topic is deleted!

    Unsolved 26 days ago
    0 Votes
    1 Posts
    37 Views
    No one has replied
  • python script integration with QT Desktop software

    Unsolved 28 days ago
    0 Votes
    5 Posts
    161 Views
    @JonB I found a good solution: pythonqt https://github.com/MeVisLab/pythonqt
  • 0 Votes
    4 Posts
    222 Views
    Use signal for parent of QScrollArea: windowStateChanged(Qt::WindowState windowState) and save/restore parameters for QScrollArea
  • 0 Votes
    3 Posts
    335 Views
    Having just come across this specific problem, it should be mentioned in the documentation here: https://doc.qt.io/qt-6/windows-building.html And if there's a cmake command line equivalent, then definitely here where the "-debug-and-release" is called out. https://doc.qt.io/qt-6/configure-options.html
  • 0 Votes
    4 Posts
    1k Views
    @stevej, see post/529035: On Windows and macOS, the native print dialog is used, which means that some QWidget and QDialog properties set on the dialog won't be respected. I can confirm on Linux that it utilises its own modal. I don't believe that a portal exists for this yet.
  • 0 Votes
    5 Posts
    400 Views
    @johnzhou721 said in How Should One Register Standard QActions in the Menu Bar to Perform the Appropriate Action?: are those edit actions usually not present if there’s multiple line edits then? The shortcut is pretty much the same as pressing Ctrl + X. What else do you want to "cut"? If there is nothing to which you can apply "cut", nothing happens. Same as if you just press Ctrl + X without selecting some file/text.
  • Include large resources using Visual Studio?

    Unsolved 28 days ago
    0 Votes
    3 Posts
    141 Views
    @Christian-Ehrlicher QT VS Tools is automatically including .qrc files, so I'm not using qt_add_resources. Also, I'm not using CMAKE.
  • 0 Votes
    5 Posts
    392 Views
    I've encountered the same. But this time on iOS, whereby the stateChanged signal stays stuck in ConnectedState, even if the central device disconnects.