Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Mismatch between QtCreator and QtDesigner - implementing "connect"



  • I have successfully implemented "connect" in QtDesigner - passing string from "list" to "plaintextEdit".

    I can implement similar "connect " in code - especially the last parameter with the help of intelisnese - all "legal".

       connect(ui->list,
                    &QListWidget::itemClicked ,
                ui->plainTextEdit,
               &QPlainTextEdit::addItem);
     
    

    But the compiler throws an error:

    /media/f/QT/Qt/QT/qtconnectivity/examples/bluetooth/CAT_BT_18112020/device.cpp:138: error: 'addItem' is not a member of 'QPlainTextEdit'
                &QPlainTextEdit::addItem);
                 ^
    

    connect(ui->list,
    &QListWidget::itemClicked ,
    ui->plainTextEdit,
    &QPlainTextEdit::addItem);

    What am I doing wrong ?



  • @AnneRanch

    QPlainTextEdit does not handle items... So it does not have any addItem function or slot.

    It's
    setPlainText
    or
    appendPlainText



  • @Pl45m4 said in MIsmatch between QtCreator and QtDesigner - implementing "connect":

    QPlainTextEdit does not handle items... So it does not have any addItem function or slot.
    It's
    setPlainText
    or
    appendPlainText

    I made an error connecting two "lists", however when I connect list and plain text using append I get an error I am unable to decipher. It also looks as my signals are not in correct sequence.

    They should be in
    push button -> initialize and show dialog - that works fine.
    dialog activated -> fill "list" with lines of text - that is done by original "btscan" connect and it is in QtDesigner (singal / slots ) and XML and that works too

    when filling the list , each "new item" should generate a signal and copy the item to "plain text". That works only once, on first "new item" detected . This is my add implemented in QtDesigner. I am not sure why it does not work on all "new / chaged" items. That is a minor issue.

    What is need is to copy "new" items to "parent " dialog.
    Ideally using same slot which is filling the "child" dialog.
    I do no know how to modify / add to XML ( and really cannot since it is system created anyway.)

    I cannot do "cross object" conncet in QtDesigner and my attempts to do this in code failed ( posted elsewhere ).

    After the above long and boring story - here are a simple and stupid question:

    is it correct to implement "connect" in class constructor ?

    to keep signals / slots in proper sequence - how do I verify that QtDesigner connection signals are "passed" to other object?

    AKA how to debug / step thru QtDesigner XML code ?



  • @AnneRanch said in MIsmatch between QtCreator and QtDesigner - implementing "connect":

    is it correct to implement "connect" in class constructor ?

    Short and simple answer: It depends.

    In general: Yes, when the connection should be valid the whole life time of the object. Basically connections can be made everywhere (as long as they make sense).

    how to debug / step thru QtDesigner XML code ?

    You can't.
    It's XML and no C++ class.

    ui_CLASSNAME.h is the corresponding C++ header file to your CLASSNAME.ui. And since it's just a header, there is nothing really going on there. It only includes the widgets, you create in QtDesigner.

    I do no know how to modify / add to XML

    Just modify your QtDesigner file.


Log in to reply