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. One more basic C++ question
Qt 6.11 is out! See what's new in the release blog

One more basic C++ question

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 274 Views 2 Watching
  • 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
    Anonymous_Banned275
    wrote on last edited by
    #1

    I am still unsure about C++ syntax . The attached "connect": code gives me errors. I need help with C++ syntax.

    /media/f/QT/Qt/QT/qtconnectivity/examples/bluetooth/CAT_BT_18112020/device.cpp:125: error: **cannot call member function** 'void QListWidget::itemClicked(QListWidgetItem*)' **without object**
         &QListWidget::itemClicked(&item), // &item),
                                        ^
    
    /media/f/QT/Qt/QT/qtconnectivity/examples/bluetooth/CAT_BT_18112020/device.cpp:127: error: cannot call member function 'void QListWidget::addItem(QListWidgetItem*)' without object
                 &QListWidget::addItem(&item));
                                            ^
    

    Please help me with understanding what I am doing wrong.
    C++ code correction would be also welcome, hopefully with explanation of my error.

       connect(ui->list,
                &QListWidget::itemClicked(&item), ,
                ui->list_2,
                &QListWidget::addItem(&item));
    
    Pl45m4P jsulmJ 2 Replies Last reply
    0
    • A Anonymous_Banned275

      I am still unsure about C++ syntax . The attached "connect": code gives me errors. I need help with C++ syntax.

      /media/f/QT/Qt/QT/qtconnectivity/examples/bluetooth/CAT_BT_18112020/device.cpp:125: error: **cannot call member function** 'void QListWidget::itemClicked(QListWidgetItem*)' **without object**
           &QListWidget::itemClicked(&item), // &item),
                                          ^
      
      /media/f/QT/Qt/QT/qtconnectivity/examples/bluetooth/CAT_BT_18112020/device.cpp:127: error: cannot call member function 'void QListWidget::addItem(QListWidgetItem*)' without object
                   &QListWidget::addItem(&item));
                                              ^
      

      Please help me with understanding what I am doing wrong.
      C++ code correction would be also welcome, hopefully with explanation of my error.

         connect(ui->list,
                  &QListWidget::itemClicked(&item), ,
                  ui->list_2,
                  &QListWidget::addItem(&item));
      
      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @AnneRanch

      Using the new signal&slot syntax, you don't need to worry about any parameters. This is done automatically.

      Remove the (&item) part on both sides (signal and slot) and it should be fine


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      4
      • A Anonymous_Banned275

        I am still unsure about C++ syntax . The attached "connect": code gives me errors. I need help with C++ syntax.

        /media/f/QT/Qt/QT/qtconnectivity/examples/bluetooth/CAT_BT_18112020/device.cpp:125: error: **cannot call member function** 'void QListWidget::itemClicked(QListWidgetItem*)' **without object**
             &QListWidget::itemClicked(&item), // &item),
                                            ^
        
        /media/f/QT/Qt/QT/qtconnectivity/examples/bluetooth/CAT_BT_18112020/device.cpp:127: error: cannot call member function 'void QListWidget::addItem(QListWidgetItem*)' without object
                     &QListWidget::addItem(&item));
                                                ^
        

        Please help me with understanding what I am doing wrong.
        C++ code correction would be also welcome, hopefully with explanation of my error.

           connect(ui->list,
                    &QListWidget::itemClicked(&item), ,
                    ui->list_2,
                    &QListWidget::addItem(&item));
        
        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @AnneRanch

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

        https://doc.qt.io/qt-5/signalsandslots.html
        If using overloaded signals see https://stackoverflow.com/questions/16794695/connecting-overloaded-signals-and-slots-in-qt-5

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

        1 Reply Last reply
        4

        • Login

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