Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.4k Topics 456.4k Posts
  • QMetaObject and QMetaProperty - why 2 times the same object?

    Unsolved
    2
    0 Votes
    2 Posts
    157 Views
    Chris KawaC
    QMetaObject is a meta object for a class, not an instance. myObject->metaObject() is basically the same as MyObjectClass::staticMetaObject. It's just a shortcut to look up the class of a given instance. Properties on the other hand have values per object. When you have a meta object , which, again, is a class descriptor and not related to any particular instance of it, you can use it to read a property. The "location" of the property in given class is described in the meta object, but to get a value from a particular instance of that class you need to pass that instance. So, if you want to avoid using the instance pointer twice you can do it like this: QVariant property = MyObjectClass::staticMetaObject.property(i).read(myObject); If you don't know the class of the object you have to use myObject->metaObject() so that it gives you the meta object of the right class.
  • Create Logging file Using Qfile

    Unsolved
    7
    0 Votes
    7 Posts
    3k Views
    M
    Thank you so much @CP71 @J-Hilk @jsulm You help me lot
  • Verifying User Login

    Unsolved
    14
    0 Votes
    14 Posts
    2k Views
    SGaistS
    And again as well, the image of the code you posted shows that your Python code is invalid. As I already explained, your use of double quotes breaks the line of code itself. The fact that your DB server does not handle double quotes is an entirely different issue that cannot be deduced neither by the information nor the code you provided. Since you did not tell which type of database you were using, nor the exact error(s) you were getting, the only obvious one was the fact that that line was invalid code. On a side note, the double quote handling of MySQL is in fact non standard so you were currently lucky with that one. Since you are using Qt, you might want to take a look at the Qt SQL module.
  • QSwipeGesture with mouse to control qstackedwidget

    Solved
    1
    0 Votes
    1 Posts
    102 Views
    No one has replied
  • Getting executable to run from command line

    Unsolved
    5
    0 Votes
    5 Posts
    671 Views
    J.HilkJ
    @ocgltd if you're on windows, you can look into the install folder of Qt and look for this bat file qtenv2.bat and if you're using MSVC also look for and execute vcvarsall.bat that should set up the environment of your command prompt to the default settings of QtCreator but this is temporary solution, the proper way is to deploy the application with the deployment tool, or by hand, like the others suggested
  • How to create .mdb or .accdb files?

    Solved
    4
    0 Votes
    4 Posts
    337 Views
    jsulmJ
    @manikanta27 said in How to create .mdb or .accdb files?: Can you help me with a sample code to copy a file to some other location See https://doc.qt.io/qt-5/qfile.html#copy-1 Yes, you can have more than one connection to a db at runtime. See https://doc.qt.io/qt-5/qsqldatabase.html, you can give each connection its own name.
  • Get size of window with debug when runtime

    Solved
    3
    0 Votes
    3 Posts
    237 Views
    mamskyM
    Hai, thanks for help, it solved. This is my latest code //mainwindow.h protected: void resizeEvent (QResizeEvent *e); //mainwindow.cpp #include <QResizeEvent> //. //. void mainwindow::resizeEvent(QResizeEvent *e) { qDebug() << e->size().width(); qDebug() << e->size().height(); qDebug() << e->size(); QWidget::resizeEvent(e); }
  • Condition to auto detect installed Qt Versions in Qt Creator

    Solved
    8
    0 Votes
    8 Posts
    8k Views
    A
    @jesperm Thanks for info. Changed the path to system location of qmake.Save me a lot of time.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • StackedWidget / TableWidget Layout dilema

    Solved
    6
    0 Votes
    6 Posts
    367 Views
    DriftwoodD
    @JoeCFD - I just did that and came back here to your same solution. I'm just now getting back into Qt after not using it for a while. Let's see what I can go dumb on next :D Thank you both for your input.
  • 0 Votes
    7 Posts
    444 Views
    SGaistS
    @ChrisW67 said in Function that return the file size of a formated resized AND copressed QImage before save()?: @SGaist said: it is even better than what I had I mind It is all roses until someone feeds you a 3.5GB image file or two. On 32 bit variant of the application ? :-)
  • Resizing QFormLayout widgets (Row length and breath)

    Unsolved
    2
    0 Votes
    2 Posts
    279 Views
    SGaistS
    Hi, Did you check the QFormLayout::fieldGrowthPolicy ?
  • QPushButton changing between checkedOff / checkedOn .png graphics

    Solved
    7
    0 Votes
    7 Posts
    295 Views
    C
    Perfect, thanks so much. ui.button01->setChecked(true);
  • How to map a ui->Widget to PaintEvent

    Solved
    2
    0 Votes
    2 Posts
    165 Views
    SGaistS
    Hi, You can't. If you want to do custom painting, you need to subclass. You can then use the promote feature of designer to use your subclass.
  • QODBC3 driver not loaded

    Unsolved
    3
    0 Votes
    3 Posts
    714 Views
    hskoglundH
    Hi, are you sure you're installing on your Raspberry and not on a PC? On my Raspberry, unixODBC gets installed in /usr/lib/arm-linux-gnueabihf not in /usr/lib/i386-linux-gnu (for example the libodbc.so.2 dll needed by Qt5's libqsqlodbc.so is in the /usr/lib/arm-linux-gnueabihf directory) Also, to build the libqsqlodbc.so ODBC3 driver you need to download Qt5 source files (that matches the version of Qt5 you have installed). More here
  • QtWebEngine and QtWebChannel deployment issue

    Unsolved
    4
    0 Votes
    4 Posts
    551 Views
    KH-219DesignK
    I have seen others mention on various forum threads that they point --qmldir to the root of where the entire Qt QML distribution exists, as in: --qmldir C:\destination\dl_third_party\Qt_desktop\5.14.0\msvc2017_64\qml This has the side-effect (which can be "good" or "bad" depending on your opinion) of shipping ALL of Qt's QML into your deployed app (even parts of the Qt QML distro that your app does not need). As I understand it, this "kitchen sink" approach bypasses whatever issue is preventing windeployqt from properly analyzing your app for its minimum needed amount of Qt QML. We bypass the problem by just deploying all QML known to humankind, essentially.
  • Updating c++ data in Qml

    Solved
    46
    0 Votes
    46 Posts
    7k Views
    J.HilkJ
    @dziko147 WUHUH congrats! If you would be so kind and use the topic tool button and set the topic to solved :D
  • Add DLL paths at runtime

    Unsolved cmake dll windows
    4
    0 Votes
    4 Posts
    4k Views
    hskoglundH
    Do you mean how to add paths so that your .exe files can be run from Qt Creator, or adding paths so that your .exe files can be run without Qt Creator? In the first case (starting .exe files from Qt Creator) as long as you only have a single version of Qt installed on your PC, there should be no need to add any paths, as I said earlier, Qt Creator adds the path to the Qt dlls for you. In the second case (starting .exe files without Qt Creator) then there are 2 ways to do it: copy the Qt dlls to the same directory that your .exe file is in, either manually or by using the windeployqt.exe program adding the path to the Qt dlls to the PATH env. variable Note: LIBS += -LMyPath has no effect on runtime lookup of .dlls or .so files QMAKE_RPATHDIR has no effect on Windows, because Windows does not support adding a list of paths to your .exe/elf file where to find the Qt dlls/so files (works only on Linux and MacOS) Also on Linux, QMAKE_RPATHDIR is not needed for the first case (starting .exe/elf files from Qt Creator) since Qt Creator does that automatically for you (by issuing a linker command e.g. -Wl,-rpath,/home/user/Qt/5.15.2/gcc_64/lib)
  • BUG or feature ?

    Unsolved
    12
    0 Votes
    12 Posts
    729 Views
    KroMignonK
    @AnneRanch said in BUG or feature ?: Are you saying that "item" as in "addItem" works differently when "item" is QString ? Yes, and it is documented, if you have read the link given by @ChrisW67 void QListWidget::addItem(QListWidgetItem *item) Warning: A QListWidgetItem can only be added to a QListWidget once. Adding the same QListWidgetItem multiple times to a QListWidget will result in undefined behavior.
  • Display issue with Qt application windows over SSH/X11

    Unsolved
    4
    0 Votes
    4 Posts
    7k Views
    Y
    This is the first place where Google gets me, when I was trying to find a solution for the issue I had, which was: Qt: QOpenGLWidget: Failed to make context current composeAndFlush: makeCurrent() failed when I used a Qt application over WSL2 with X11 forwarding to my Windows host with VcXsrv. I understand this topic/question is old, but It would save me Googling time if someone described here a similar problem as I had. What I did wrong in my case was setting LIBGL_ALWAYS_INDIRECT env variable (it was set to 1). As suggested in this Stackoverflow post - unset it, and unset the "Native opengl" checkbox in VcXsrv XLaunch UI, and that fixes the runtime: export LIBGL_ALWAYS_INDIRECT= I'm on latest Windows 11 Preview with VcXsrv 1.20.9 + Ubuntu 20.04 over WSL2 with Qt 5.15.2. My Qt Application also sets: QGuiApplication::setAttribute(Qt::AA_UseDesktopOpenGL); QGuiApplication::setAttribute(Qt::AA_ShareOpenGLContexts);