Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.4k Posts
  • Qt6. Embedding native widgets in QTabWidget/QStackedWidget breaks their geometry

    Unsolved
    4
    0 Votes
    4 Posts
    118 Views
    N
    Tested with Qt 6.10.0-0-202510021201, the same problem
  • QMAKE: Visibility of variables defined in .pro file with SUBDIRS

    Solved
    8
    1 Votes
    8 Posts
    138 Views
    R
    I have found a solution which involves two top-level SUBDIRS projects, one "app" project (i.e. with "TEMPLATE = app"), and three "TEMPLATE = lib" subprojects. It's actually quite possible to put the app project file in the same folder as the top-level SUBDIRS project if you use the .file syntax on the target dependencies. Here is the directory structure, similar to my other post above, but a little different: TOP_Project_Dir |__3rd_party |__A |__src |__A_lib.hpp |__A_lib.cpp A_lib.pro |__B <== (similar to A) |__C <== (similar to A) Libs.pro .qmake.conf |__app |__lib |__src App.pro Project.pro .qmake.conf |__build |__Project |__Qt-<version> |__Debug |__Release Here is the top-level Project.pro file: TEMPLATE = subdirs SUBDIRS = Libs App lessThan(QT_MAJOR_VERSION,6):CONFIG+=ordered APP_DIR = $$top_srcdir THIRD_DIR = $$clean_path($${APP_DIR}/../3rd_party) Libs.file = $${THIRD_DIR}/Libs.pro App.file = $${APP_DIR}/App.pro App.depends = Libs The Libs.pro file: TEMPLATE = subdirs SUBDIRS = \ A/A_lib.pro \ B/B_lib.pro \ C/C_lib.pro Here it was more convenient to just refer directly to the file paths in the SUBDIRS section. The A_lib.pro file (and almost exactly the same for B and C libraries): CONFIG -= qt TEMPLATE = lib CONFIG += static c++17 release SOURCES += \ src/A_lib.cpp HEADERS += \ src/A_lib.hpp TARGET = A PROJECT_DIR = $$clean_path($${top_srcdir}/../) APP_DIR = $${PROJECT_DIR}/app DESTDIR = $${APP_DIR}/lib Finally, the App.pro file: CONFIG -= qt TEMPLATE = app TARGET = MyApp CONFIG += c++17 console APP_DIR = $${top_srcdir} LIB_DIR = $${APP_DIR}/lib SRC_DIR = $${APP_DIR}/src THIRD_DIR = $$clean_path("$$top_srcdir/../3rd_party") OBJECTS_DIR = $${top_builddir}/.obj MOC_DIR = $${top_builddir}/.moc RCC_DIR = $${top_builddir}/.qrc UI_DIR = $${top_builddir}/.ui DESTDIR = $${top_builddir}/exec SOURCES += $${SRC_DIR}/theApp.cpp LIBS += -L"$${LIB_DIR}" -lA -lB -lC INCLUDEPATH += \ $${THIRD_DIR}/A/src \ $${THIRD_DIR}/B/src \ $${THIRD_DIR}/C/src Here is the source of A_lib.hpp and A_lib.cpp which is about the same for B and C: // A_lib.hpp #ifndef A_HPP #define A_HPP namespace A { void whoAmI(); } #endif // A_lib.cpp #include "A_lib.hpp" #include <iostream> namespace A { void whoAmI() { using namespace std; cout << "I'm in A lib" << endl; } } Finally, theApp.cpp file: #include "A_lib.hpp" #include "B_lib.hpp" #include "C_lib.hpp" int main() { A::whoAmI(); B::whoAmI(); C::whoAmI(); } In the Qt Creator "Default Build Properties" under "Build & Run", I have this template set for the default build directory: ../build/%{Project:Name}/Qt-%{Qt:Version}/%{BuildConfig:Name} This gives me for my little project this build directory in Debug mode: $HOME/code/TOP_Project_Dir/build/Project/Qt-5.15.13/Debug This is nice because "TOP_Project_Dir/3rd_party" and "TOP_Project_Dir/app" are under source-code management ("SCM", I am using Fossil for the real project) but in two different repositories, and everything under "build" gets ignored. The information @KH-219Design and @SGaist gave me was important to making this work. The sticking point, though, was that both of the top-level .pro files with TEMPLATE=subdirs needed to be parallel to each other, i.e. at the same level relative to the TOP_Project_Dir folder. These also need to be under SCM, so if one was on a different level, the build output of one would have gotten in the way of the other. Marking this now as SOLVED!
  • Please help,Drag and drop to a QgraphicsView

    Solved
    5
    0 Votes
    5 Posts
    85 Views
    E
    @SGaist thank you so much ,now it works, all that was missing was the QDragMoveEvent.
  • 0 Votes
    3 Posts
    82 Views
    F
    @SGaist said in QMenu appears under fullscreen MainWindow on Windows (works on Ubuntu): Hi and welcome to devnet, Which version of Qt 5 exactly ? Do you have the same issue if you use Qt 6 ? Hi I’m currently using Qt 5.15.2 on Windows 10. I need to continue my project with Qt 5, and at the moment I don’t have the possibility to switch versions to check whether it works correctly with Qt 6.
  • AccessibleName for QPushButton stopped working in the 6.9.2 with the QTabWidget

    Solved
    32
    0 Votes
    32 Posts
    923 Views
    O
    And I fixed it under 6.9.2. The cause is in "app.setStyleSheet(styleSheet); " position in the main.cpp file :). I'm surprised why it worked so long in previous Qt versions :). It was (style issue): app.setStyleSheet(styleSheet); MainWindow win; win.show(); The problem is predictable :( It needs to be: MainWindow win; app.setStyleSheet(styleSheet); win.show(); It's more logical. Firstly create GUI, then apply style :) I think, the problem has resolved.
  • Incorrect position of fenestration under Wayland.

    Unsolved
    5
    0 Votes
    5 Posts
    399 Views
    F
    Oh, the second solution does not work. The shell integration could not be loaded, so the qpa plugin wayland could not be loaded, so it uses xcb as a fallback. It worked, so i didn't read the debug carefully, sorry.
  • Detect current CMake configuration type. How?

    Solved
    22
    0 Votes
    22 Posts
    723 Views
    B
    Just look on situation when you developing application that is for Android, Unix, iOS, MacOS from one source. And you application has DIFFERENT sets of files for Debug and Release. ONLY ONE way to use this different sets with XCode - to have debug/release settings in CMake, BEFORE XCode. Using expressions in CMake for definitions sets for XCode is impossible. All things that you've got written is about blocking normal developing for iOS. You require me to develop in separate way for iOS. CMAKE_BUILD_TYPE IS USED FOR CREATING DIFFERENT VERSIONS OF PROJECT AUTOMATICALLY BEFORE XCODE. Think of real world application but not of what XCode using or not. This settings for defining project structure not for XCode. The sets of file require NOT ONLY the CPP sources. It require icons, settings, even different Info.plist files and many other things. How you going to setup this things with #ifndef NDEBUG??? If you going to advise me to use something like this: $<$CONFIG:Debug:${CMAKE_CURRENT_SOURCE_DIR}/dbgsrc.cpp> Try to do it by yourself you will have error from XCode that it's not supported sources that have vary in configurations from expressions. In this case only one way is using CMAKE_BUILD_TYPE to set different type of projects within different sets of files at time of scanning and this scanned project passing to XCode.
  • Genericity, extensibility and reuse: QWidgets Vs QML

    Solved qml c++ qml qwidget performance template
    8
    1 Votes
    8 Posts
    1k Views
    G
    I have picked up QML about three weeks ago and I am liking it very much; I have been implementing some small program with PySide6 and QML and it is a pleasure to program in it, but I do find that I can't find examples; currently, I can't get a TableView to work with the ability to edit values....where can I get some assistance?
  • Issue in qvulkanwindow.cpp ?

    Unsolved
    7
    1 Votes
    7 Posts
    615 Views
    J
    Happens to me for version 6.9.2. Swapchain image count is 3. validation errors are sporadically appearing, would suggest that sometimes timing is just right to divide 3 swapchain images to synchronization with 2 semaphores isnt it also exactly this? https://docs.vulkan.org/guide/latest/swapchain_semaphore_reuse.html
  • Whither (many) examples?

    Unsolved
    4
    1 Votes
    4 Posts
    91 Views
    SGaistS
    @FeRDNYC hi, This being a user forum you might not reaching the right people. I would recommend opening a ticket on the bug report system to spark the discussion around the issue of moving the examples.
  • Question about SUBDIRS template in qmake

    Unsolved
    2
    0 Votes
    2 Posts
    45 Views
    SGaistS
    Hi, Subdirs project are full-blown so your original idea won't work. The static libraries is the correct option.
  • Q_INCLUDE_MOC vs Q_DECLARE_OPAQUE_POINTER

    Unsolved
    4
    0 Votes
    4 Posts
    528 Views
    F
    I got into similar situation today, but I had to use Q_MOC_INCLUDE because the class is a Q_OBJECT in my case. The Qt docs suggest that Q_DECLARE_OPAQUE_POINTER is incompatible in this case. Hope this helps!
  • Drag and drop to a QgraphicsView

    Unsolved
    2
    0 Votes
    2 Posts
    43 Views
    JonBJ
    @electric-dev And what happens? Are you going to tell us whether either your dragEnterEvent() or dropEvent() are ever called? Please use the forum's Code tags (``` above & below, or the </> toolbutton) when pasting code especially for Python where indentation matters.
  • vkAcquireNextImageKHR say that Semaphore must not have any pending operations

    Unsolved
    1
    0 Votes
    1 Posts
    48 Views
    No one has replied
  • QPageSetupDialog not displaying, returns error

    Solved
    5
    0 Votes
    5 Posts
    261 Views
    SprezzaturaS
    Also, the "Qt...DLL" files should not be copied to the EXE directory.
  • 0 Votes
    2 Posts
    47 Views
    Pl45m4P
    @vedansh If your account was upgraded to Enterprise you need to downgrade to a free / open source license somehow. Or create a new Qt account. Best is to contact Qt sales directly.
  • How to include files from the subproject dll library in a unit testing subproject

    Unsolved
    3
    0 Votes
    3 Posts
    54 Views
    Pl45m4P
    @Stanislav228 Hi and welcome to the forum, I don't quite understand your issue. You don't need to add the EXPORT to all functions/classes of your library. You can still hide some classes or functions that you don't want in your target that imports the lib. Everything works until I add the q_decl_export directive to the classes in the dll. What should I do? What does not work then?! How do you add the import/export directives to your project? Are you using the "Qt-Global" style?!
  • 0 Votes
    15 Posts
    129 Views
    S
    To add on to this, I discovered why it was trying to insert NULL for relation fields. I did the select before setting my relations. And it wasn't enough to have a separate model load the related table. It has to be loaded in the QSqlRelationTableModel for it to work. So the very original comment here (sorry if this pings you) turned out to be 100% correct. I'm just also posting this here for future reference @JonB said in QSqlRecord forces null in composite primary key on QSqlTableModel::insertRecord: Isn't that actually a consequence of you using a QSqlRelationalTableModel? Isn't it that the Qt side expects to see in the related FoodData table/model an entry for the value of your food column in FoodDay table/model equal to it? You have "broken the contract" you establish with QSqlRelationalTableModel that Qt will see in-memory models maintaining the relationship? It is not good enough if you say the row does exist at the backend database side, if you want to use QSqlRelationalTableModel (you don't have to, it's only for value lookup) you must have the FK model/table up-to-date in memory.
  • How to exclude a specific widget from the global stylesheet?

    Unsolved
    5
    0 Votes
    5 Posts
    96 Views
    S
    You can see if any of the selectors (https://doc.qt.io/qt-6/stylesheet-syntax.html) work for you. You could create your own subclass of QPushButton. As long as all the other buttons are actual QPushButtons the class selector .QPushButton would only style these, but not your subclass. Or you could try to use a Property Selector with your own property. But I'm not sure if that works for buttons that don't have that property. (You see, it is a lot easier to just specify something for a specific button, but a lot harder to specify something for all other buttons.)
  • QSqlTableModel Network Performance

    Unsolved
    16
    0 Votes
    16 Posts
    270 Views
    Kent-DorfmanK
    Full tableview models over an internet are bad ju-ju. You should switch to a client/server transaction model. It's ok to load managable chunks into a local table presentation, but you MUST limit the number of returned rows and use indexes properly. Never blindly load a table. Doing that means you are not using the relational database properly. Only time you should ever need full table access is during maintenance as a DBA, but even then it's not strictly necessary. trying to predict and manage latency won't solve your problems. When you switch to a networked database model your access mechanisms have to allow for unpredictable latency. Some hints make sure your SQL is being executed as stored procedures on the database server where the data is hosted, not the local machine..."cloud" should make you nervous if the table data isn't stored on the same machine as the DB server. switch to a rigid transaction model rather than a table view model make effective use of proper indexing and limiting of SQL result sets Sorry to be the voice of gloom, but local DB and network are two different worlds.