Skip to content
  • 0 Votes
    10 Posts
    2k Views
    M
    @JonB said in Qt Mysql [Mysql Server has gone away] and Silent failures after query exec(): @mvsri said in Qt Mysql [Mysql Server has gone away] and Silent failures after query exec(): like 10+ hours any statements like update or insert doesn't work. This may be significant. From your INSERT example you are using prepare() and you are binding variables. Please read https://forum.qt.io/topic/107690/lost-connection-to-mysql-server-during-query-qmysql3-unable-to-reset-statement carefully. There the suggestion is that this may fail to reconnect even with the reconnection option. If your problem is reproducible can you, at least temporarily/as a test change to make the query a string with whatever in it and abandon preparation and variable substitution? Does that make the problem go away? Furthermore, you check the result of exec() but when you do use prepare() you do not check the result it returns. You should do so. That may reveal an error at that stage. Also, given that abandonment of MYSQL_OPT_RECONNECT has either happened or is about to happen, you might remove this from your code and do whatever you have to manage reconnection yourself, to see whether that improves the situation. I do not know why your other audit log connection appears to work while your main one fails. Even more complex is your "writes to MySQL via QtConcurrent::run". I was under the impression that Qt requires you to write to a SQL connection from the same thread as where it was created/currently lives, won't QtConcurrent::run() break precisely that rule? Yet that one works. Who knows?! I have gone through this thread: https://forum.qt.io/topic/107690/lost-connection-to-mysql-server-during-query-qmysql3-unable-to-reset-statement/6. In my case, I’ve been using QString to build the query and pass it to the functions in databaseconnector class and passing it to QSqlQuery. To recreate the issue, I restarted the MySQL server from Services (windows), and I received the same error: Lost connection to MySQL server during query QMYSQL: Unable to execute query" (:0, ) After this, I implemented reconnection logic that attempts to reconnect if QSqlQuery::exec() fails and give connection error. When I recreated the same scenario (restarting the MySQL server), the reconnection worked as expected. Based on suggestions and further reading of the documentation, I’ve also modified my code to avoid holding the QSqlDatabase instance as a class variable and instead use it as a function-local variable. Regarding the AuditLogger class, I’ve completely reimplemented it and now use QMetaObject::invokeMethod for logging operations. While reviewing the documentation and googling for MYSQL_OPT_RECONNECT, it appears this option may no longer work as expected with recent versions. So, I’m considering removing it from the code. One pending task is to check the MySQL server logs—I haven’t received them yet, but once I do, I’ll analyze them for further insight. One doubt I have is: The system where the application is running is part of a domain network, governed by Group IT policies, and has antivirus installed. Could this environment be a potential cause for the dropped connection? (I understand this might be a naive question, but I’d like to rule out any possible cause.) Thank you again for your inputs—they’ve helped clarify several concepts for me.
  • QMLLS not finding manual C++ registrations

    Solved QML and Qt Quick qml qmlls cpp registration class
    4
    0 Votes
    4 Posts
    689 Views
    ekkescornerE
    instead of setContextProperty() you should use QML_SINGLETON see: https://t1p.de/ekkeQML_SINGLETON
  • ‘signals’ and 'public slots' does not name a type

    Unsolved General and Desktop cpp qt6.6 qmlc++
    11
    0 Votes
    11 Posts
    2k Views
    Ronel_qtmasterR
    @SimonSchroeder OKay thanks.We shall see when he explain more
  • Experienced C++/Qt Developer Seeking remote Opportunities

    Unsolved Jobs remote cpp qt5.7 developer
    6
    0 Votes
    6 Posts
    2k Views
    stackprogramerS
    @Venkat_QT I did it. Thank you.
  • Can't connect cpp to qml project

    Unsolved Qt for MCUs mcu cpp main stm32f7
    3
    0 Votes
    3 Posts
    882 Views
    A
    @sierdzio Thank you very much for the answer. I tried some tips, but unfortunately not all were applicable in my case, since let's say the same Q_OBJECT is missing in Qt microcontrollers. And in the examples that I'm looking at, it seems that there is no such thing (Q_OBJECT), which is why I ran into a problem, since everything works in the usual Qt for Desktop but not in Qt MCU
  • 0 Votes
    8 Posts
    2k Views
    B
    Ok thanks! I think I understand what I have to do
  • How to exploit a json file in QT ?

    Unsolved General and Desktop json cpp
    28
    0 Votes
    28 Posts
    7k Views
    F
    @jsulm said in How to exploit a json file in QT ?: @feedain You already have this code snippet here, did you notice it? obj["State"] = int(state); yes thanks
  • 0 Votes
    3 Posts
    890 Views
    BDC_PatrickB
    @JonB Thanks.. found out, that i needed to create a new Pointer in the Declaration of the .h File.. Means.. TGS_Widget_AssetList * _assetList; Wasn´t enough... I needed to do: TGS_Widget_AssetList *_assetList = new TGS_Widget_AssetList(this); or auto *_assetList = new TGS_Widget_AssetList(this); Now it works.. i will update my initial post here
  • 0 Votes
    2 Posts
    627 Views
    BDC_PatrickB
    Anyone? T_T
  • 0 Votes
    4 Posts
    774 Views
    BDC_PatrickB
    @jsulm & @J-Hilk Thank you so much. You´re my Heroes :D Everyday something new to learn :)
  • Can I get rid of the *.ui files?

    Unsolved General and Desktop cmake code editor cpp clion-ide
    4
    0 Votes
    4 Posts
    2k Views
    BDC_PatrickB
    Thanks Guys.. helped me out alot :D
  • 0 Votes
    2 Posts
    614 Views
    GrecKoG
    Take a look at VXYModelMapper . It lets you create series from a QAbstractTableModel with not all the glue code you did here.
  • 0 Votes
    2 Posts
    1k Views
    sierdzioS
    @aria_aa said in how too add an exciting ".ui" file to a "cpp widget application project"?: What should I do? clean up the build directory run qmake rebuild project Should work, code looks good. And another question: what is #include "ui_window_no_000.h" and #include "ui_window_no_001.h" in cpp files? there is no file such as ui_window_no_000.h or ui_window_no_001.h in project. These files are automatically generated from your .ui files by uic. It's part of the build process in Qt, same as with it running moc to generate meta-object functionality.
  • 0 Votes
    3 Posts
    892 Views
    BDC_PatrickB
    @eyllanesc Works like a Charme! Thanks Mate!! :D
  • 0 Votes
    6 Posts
    1k Views
    KroMignonK
    @elypheldia said in How I listen serial port with writing client code?: Sorry if used the wrong term. I am new on qt. I wanted to indicate that I read the data I wrote to the tnt0 serial port from terminal with using cat /dev/tnt0. But How can I do this with client code instead of reading from terminal. I just wanna open the tnt1 serial port from code., and I wanna read from there. You are confusing to me. Do you want to use /dev/tnt0 or /dev/tnt1? With the code example you have provided, you are writing hello on serial device /dev/tnt0. Is this working? You have defined a slot MySerialPort::readData() , which is called when data are ready to be read from serial port. I have proposed you some changes to display debug message when slot is called. Is this slot called? I don't know: what kind of device is connected to this serial port? if the serial port configuration is correct according to attached device? the attached device communication protocol: It is a binary or text protocol? Are carriage return or line feed required?
  • 0 Votes
    16 Posts
    2k Views
    E
    @J-Hilk Thank you all guys for your patient and sorry for my basic mistakes :). I fixed my issue. As you said, I expect the read without writing a data to serial port.
  • QT + Cmake + GTest = Test end up to be fatal

    Unsolved General and Desktop cmake gtest fatal cpp
    21
    0 Votes
    21 Posts
    6k Views
    SGaistS
    Well, there's nothing to fix, the output matches what your test does.
  • Get all Widgets of Type <Type> ?

    Unsolved General and Desktop cpp qwidget qaction
    7
    0 Votes
    7 Posts
    4k Views
    JonBJ
    @BDC_Patrick said in Get all Widgets of Type <Type> ?: But, this only works, if i put the code directly into the construct function of the Window itself (after ui->setupUi...). Why? It's QObject::findChilden(), you can use it for any widget. But, i thought more of a Function in a seperated file, that all Windows can make use of. If you really want it in a separate file then pass the parent widget as a parameter. Are you using Qt's support for cross-language?
  • Problem z utworzeniem projektu

    Unsolved Polish cpp editor cpp
    1
    0 Votes
    1 Posts
    773 Views
    No one has replied