Skip to content
  • 0 Votes
    2 Posts
    82 Views
    SGaistS

    Hi,

    Are you sure your database connection is still opened when arriving in the cleanup function ?

  • 0 Votes
    13 Posts
    1k Views
    C

    @JKSH Not applicable because I have other event sink classes.
    Also, I use the SLOT string because (for the sake of keeping this post clear, I didn't demonstrate that) I have file-open scenarios too: void OnSingleSelect(const QString &file) and void OnMultiSelect(const QStringList &files). They don't share signatures, so either I need to template-ize (which doesn't work well w/ signals&slots), or to repeat and tweak the helper function.
    Wait: will selectedFilter trigger setDefaultSuffix along with selectNameFilter? Didn't find evidence in the source tree.
    Also again: Linux Qt 5.6.1, selectedFilter doesn't setDefaultSuffix. Call chain according to https://code.qt.io/cgit/qt/qtbase.git/plain/src/widgets/dialogs/qfiledialog.cpp :
    QFileDialog::getSaveFileName -> QFileDialog::getSaveFileUrl -> QFileDialog::selectNameFilter -> QFileDialogPrivate::_q_useNameFilter, which doesn't seem to be doing the work (at least, in my case) after the user clicked OK.

  • 0 Votes
    3 Posts
    224 Views
    D

    @jsulm Thank you

  • 0 Votes
    5 Posts
    696 Views
    X

    @J-Hilk Thanks! Hope it can be fixed soon.
    @jsulm Same thanks!

  • 0 Votes
    2 Posts
    341 Views
    jsulmJ

    @texasRanger Why do you think you need an additional event loop? From your description I don't see any need for it. If file is changed you will get a signal from file watcher. You just need to make sure parsing of that file does not take too long.

  • 0 Votes
    5 Posts
    491 Views
    eyllanescE

    Your code shows a lot of ignorance of how Qt works, as they point out, I recommend you read the docs urgently. Here no thread is necessary, it is only necessary to use the Qt event loop. Forget about sequential programming (Qt hates while true since they are not needed). You also do not know what the Qt signals are and how they are used.

    Also you do not understand the advantages and restrictions of threads, it is not safe to access and modify variables in different threads as you try to do.

  • 0 Votes
    9 Posts
    688 Views
    mrjjM

    @JonnyQB
    Hi
    You declare it like
    Punkte * punkten;

    Then some place else you must do
    punkten = new Punkte(); ( not in .h)
    Often the constructor is a good place.

  • 0 Votes
    13 Posts
    6k Views
    SGaistS

    Hi,

    Where do you get that ID ?

    You'll click on the action, get the ID and then call the slot ?

  • 0 Votes
    7 Posts
    2k Views
    Pradeep KumarP

    @Kalado said in Connect() uses wrong emitter object.:

    Look at some code:

    //A.h class task2 : public QWidget { Q_OBJECT public: task2(QWidget *parent = 0); ~task2(); protected: void mousePressEvent(QMouseEvent *event) override; signals: void myWidgetClicked(); //A.cpp void A::mousePressEvent(QMouseEvent *event){ /// use the respective classname emit myWidgetClicked(); }

    If ur using Classname as task2 , use

    void task2::mousePressEvent(QMouseEvent *event){ emit myWidgetClicked(); }

    Thanks,

  • 0 Votes
    4 Posts
    6k Views
    mrjjM
    difference between exec() and show(),
    Only QDialog have exec() Qwidgets have show.
    When you call show on a Dialog, it becomes visible but do not
    wait for input.
    example mainw::func() { MyDialog *dia=new MyDialog(this); dia->show(); int a=0; // this code is run the moment dialog is shown on screen, } using exec() mainw::func() { MyDialog dia; dia.exec(); int a=0; // this code is run only after dialog is dismissed. }

    The version of dialog where u call show() could be called floating so when user click ok
    it should emit signal that something should happen. ( to maiwindow )

    The exec() version will report back the result ok/cancel/closed at once.

    learn when to use QObject, QWidget, QFrame
    QWidget is often used if making own widget. QFrame is used if you just need something to draw
    a frame. If you use Designer you can check out the Widgets that are available.
    QDialog is useful for any type of windows that pop ups up or open via a menu.

    I have to set anything inside Register.
    Yes, Register should be able to give the data back.
    the widgets inside are private so you need a function to return the data.
    You might also need to call
    http://doc.qt.io/qt-5/qdialog.html#accept
    in your Register buttons clicked slot.

  • 0 Votes
    8 Posts
    4k Views
    divergerD

    @jsulm Thanks, I'll give it a try.

  • 0 Votes
    12 Posts
    10k Views
    McLionM

    @VRonin
    Thanks for your input - there seem to be some misunderstanding.
    I can not and do not want to wait for the acknowledge of the server as a trigger to sent the next log message - this is against the idea.
    Log messages need always to be sent, regardless wether the server acknowledges or not - imagine the server even does not acknowledge.

    Every message sent has an ID# that is incremented by one for every new log message sent.
    The server acknowledges every message with returning the ID#.

    Looking at the network of the server with Wireshark and having incoming log messages with time stamps of the same msec - obviously the server has no time to send the acknowledge between incoming protocols. I.e. Sending #1 and # 2 in such a short sequence, obviously when sending #2 the counter for a missed message goes up to one.
    This is inherit by this system and is by design.

    Therefore, I'm going to implement a gap of at least a few msec between sending messages.
    Because the messages are all handled and forwarded in the application by signals / QtEvent queues, I dont have a solid idea so far how to do this.
    I may have to create a time gated sending queue before handing the messages over to the signal and the QtEvent queue.

  • 0 Votes
    7 Posts
    6k Views
    beeckscheB

    @kshegunov said:

    the way the API is organized is a bit different from QTcpSocket

    You're right. I was also a little bit confused, when i used the QSerialBus module the first time (see my topic https://forum.qt.io/topic/65572/qmodbusmaster-example).

    Like i said, i think you can built your own class by inherit from QModbusDevice to have a synchronous API. The QSerialBus module is marked as technical preview in Qt 5.6, maybe they add some new functions in future releases similar to QTcpSocket like waitForConnected etc.

  • 0 Votes
    9 Posts
    7k Views
    D

    Hi,
    Thanks for your response. The whole body of code is proprietary so I'm not sure I can share it in a public forum.
    However I can make a note that it used to work fine a month ago and after that no changes occurred to this code and no qt libraries were replaced, so the issue is like to be caused by hardware malfunction.

    Thanks again ))

  • 0 Votes
    5 Posts
    5k Views
    cxamC

    @mrjj Thanks :)

  • 0 Votes
    15 Posts
    6k Views
    cxamC

    @mrjj Hi! I managed to make everything just as I wanted, everything is going fine. The code example you sent me really did the trick. Thanks a lot.

  • 0 Votes
    4 Posts
    940 Views
    SGaistS

    Hi,

    On a side note, there's no need to use fromStdString to initialize a QByteArray with a string.