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

Using the same device created with QCanBusDevice in two dilaog



  • I created a device in dialog

    QCanBusDevice *device1 = QCanBus::instance()->createDevice(
       QStringLiteral("peakcan"), QStringLiteral("usb0"), &errorString1);
    

    and I have button named Com when I clicked on button Com a new dilog2 display

    void ConnectDialog::on_pushButton_com_pressed()
    {
        Com com;
        com.setModal(true);
        com.exec();
    
    }
    
    

    How Can I use the same device in the dialog2 ?
    I tried to create a second device again but it doesn't work ..
    thank u for helping me


  • Lifetime Qt Champion

    @alpacino said in Using the same device created with QCanBusDevice in two dilaog:

    How Can I use the same device in the dialog2 ?

    Pass the pointer to the device as parameter to the dialog constructor...



  • hi @jsulm you mean like that

    Com::Com(QWidget *parent,ConnectDialog *device1) :
        QDialog(parent),
        ui(new Ui::Com)
    

    when I do it as mentioned an error occur

    com.cpp:21:6: error: out-of-line definition of 'Com' does not match any declaration in 'Com'
    

    give me an example if you have and thank you


Log in to reply