Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Using the same device created with QCanBusDevice in two dilaog

Using the same device created with QCanBusDevice in two dilaog

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 277 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    alpacino
    wrote on last edited by
    #1

    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

    jsulmJ 1 Reply Last reply
    0
    • A alpacino

      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

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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...

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        alpacino
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved