Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Error in connecting Signals and slots qt6 lineEdit

Error in connecting Signals and slots qt6 lineEdit

Scheduled Pinned Locked Moved Solved Qt 6
14 Posts 5 Posters 2.1k 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.
  • Y Offline
    Y Offline
    yegender
    wrote on last edited by
    #1

    Hi everyone,

    I don't know why this code

    QObject::connect(Search, SIGNAL(&QLineEdit::textChanged),
                this,SLOT(&YoutubeTopBar::ChangeSearchStyleSheet));
    

    says that error: No matching member function for call to 'connect'

    Thank you

    jsulmJ 1 Reply Last reply
    0
    • Y yegender

      Hi everyone,

      I don't know why this code

      QObject::connect(Search, SIGNAL(&QLineEdit::textChanged),
                  this,SLOT(&YoutubeTopBar::ChangeSearchStyleSheet));
      

      says that error: No matching member function for call to 'connect'

      Thank you

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

      @yegender Because it's wrong.
      If you really want to use the old connect syntax then do it properly:

      QObject::connect(Search, SIGNAL(textChanged(const QString)),
                       this,SLOT(ChangeSearchStyleSheet(const QString)));
      

      Better to use "new" Qt5 connect syntax.

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

      1 Reply Last reply
      4
      • Y Offline
        Y Offline
        yegender
        wrote on last edited by
        #3

        None of new and old are working, I tried it with the code you sent same error

        jsulmJ 1 Reply Last reply
        0
        • mranger90M Offline
          mranger90M Offline
          mranger90
          wrote on last edited by
          #4

          @yegender said in Error in connecting Signals and slots qt6 lineEdit:

          QObject::connect(Search, SIGNAL(&QLineEdit::textChanged),
          this,SLOT(&YoutubeTopBar::ChangeSearchStyleSheet));

          Just use the "new" syntax:
          QObject::connect(Search, &QLineEdit::textChanged,
          this, &YoutubeTopBar::ChangeSearchStyleSheet);

          Assuming that "Search" is a pointer-to-QLineEdit

          1 Reply Last reply
          2
          • Y yegender

            None of new and old are working, I tried it with the code you sent same error

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

            @yegender said in Error in connecting Signals and slots qt6 lineEdit:

            None of new and old are working

            Show the code.
            And please show us also YoutubeTopBar definition else nobody know what you have there...

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

            1 Reply Last reply
            1
            • Y Offline
              Y Offline
              yegender
              wrote on last edited by
              #6

              Here is the code:

              Header:

              #ifndef YOUTUBETOPBAR_H
              #define YOUTUBETOPBAR_H
              
              #include <QWidget>
              #include <QVBoxLayout>
              #include <QHBoxLayout>
              #include <QLabel>
              #include <QLineEdit>
              #include <QToolButton>
              #include <QObject>
              class YoutubeTopBar : public QWidget
              {
                  Q_OBJECT
              public:
                  explicit YoutubeTopBar(QWidget *parent = nullptr);
                  QHBoxLayout mainLayout;
                  QToolButton ToogleLeftPane;
                  QToolButton YoutubeHome;
                  QToolButton ToogleDownloadManager;
                  QToolButton ToogleSettings;
                  QLineEdit Search;
              
              
              public slots:
                  void ChangeSearchStyleSheet();
              signals:
              
              };
              
              #endif // YOUTUBELEFTPANE_H
              
              

              Source File:

              #include "youtubetopbar.h"
              
              YoutubeTopBar::YoutubeTopBar(QWidget *parent)
                  : QWidget{parent}
              {
                  this->setWindowTitle("YT Top Bar");
                  this->setLayout(&mainLayout);
                  mainLayout.setMargin(0);
                  mainLayout.setSpacing(0);
              
                  mainLayout.addWidget(&ToogleLeftPane);
                  mainLayout.addWidget(&YoutubeHome);
                  mainLayout.addWidget(&Search);
                  mainLayout.addWidget(&ToogleDownloadManager);
                  mainLayout.addWidget(&ToogleSettings);
              
                  ToogleLeftPane.setText("Toogle Left Pane");
                  ToogleLeftPane.setStyleSheet("QToolButton{"
                                               "background-color:rgba(0,0,0,0.6);"
                                               "color:white;"
                                               "border:none;"
                                               "margin:5px;"
                                               "padding:10px;"
                                               "}"
                                               "QToolButton::hover{"
                                               "background-color:rgba(255,255,255,0.1);"
                                               "border-radius:5px;"
                                               "}");
                  YoutubeHome.setText("Youtube");
                  YoutubeHome.setStyleSheet("QToolButton{"
                                            "background-color:rgba(0,0,0,0.6);"
                                            "color:white;"
                                            "border:none;"
                                            "margin:5px;"
                                            "padding:10px;"
                                            "}"
                                            "QToolButton::hover{"
                                            "background-color:rgba(255,255,255,0.1);"
                                            "border-radius:5px;"
                                            "}");
                  ToogleSettings.setText("Settings");
                  ToogleSettings.setStyleSheet("QToolButton{"
                                               "background-color:rgba(0,0,0,0.6);"
                                               "color:white;"
                                               "border:none;"
                                               "margin:5px;"
                                               "padding:10px;"
                                               "}"
                                               "QToolButton::hover{"
                                               "background-color:rgba(255,255,255,0.1);"
                                               "border-radius:5px;"
                                               "}");
                  ToogleDownloadManager.setText("Download Manager");
                  ToogleDownloadManager.setStyleSheet("QToolButton{"
                                                      "background-color:rgba(0,0,0,0.6);"
                                                      "color:white;"
                                                      "border:none;"
                                                      "margin:5px;"
                                                      "padding:10px;"
                                                      "}"
                                                      "QToolButton::hover{"
                                                      "background-color:rgba(255,255,255,0.1);"
                                                      "border-radius:5px;"
                                                      "}");
                  Search.setPlaceholderText("Search");
                  Search.setStyleSheet("QLineEdit{"
                                       "background-color:rgba(0,0,0,0.3);"
                                       "border:none;"
                                       "margin:5px;"
                                       "padding:10px;"
                                       "border-radius:5px;"
                                       "}"
                                       "QLineEdit::hover{"
                                       "background-color:rgba(255,255,255,0.1);"
                                       "border-radius:5px;"
                                       "}");
              
                  QObject::connect(Search, &QLineEdit::textChanged),this,&YoutubeTopBar::ChangeSearchStyleSheet);
              }
              
              void YoutubeTopBar::ChangeSearchStyleSheet(){
                  if(Search.text().isEmpty()){
                      Search.setStyleSheet("color:rgba(255,255,255,0.6);");
                  } else {
                      Search.setStyleSheet("color:white;");
                  }
              }
              
              

              CMAKE:

              cmake_minimum_required(VERSION 3.5)
              
              project(video-player VERSION 0.1 LANGUAGES CXX)
              
              set(CMAKE_INCLUDE_CURRENT_DIR ON)
              
              set(CMAKE_AUTOUIC ON)
              set(CMAKE_AUTOMOC ON)
              set(CMAKE_AUTORCC ON)
              
              set(CMAKE_CXX_STANDARD 17)
              set(CMAKE_CXX_STANDARD_REQUIRED ON)
              
              find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
              find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
              
              set(PROJECT_SOURCES
                      main.cpp
                      mainwindow.cpp mainwindow.h
                      youtubeleftpane.h youtubeleftpane.cpp
                      youtubetopbar.h youtubetopbar.cpp
                      youtubebanner.h youtubebanner.cpp
                      youtubepage.h youtubepage.cpp
                      youtubetopbarwrapper.h youtubetopbarwrapper.cpp
              )
              
              if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
                  qt_add_executable(video-player
                      MANUAL_FINALIZATION
                      ${PROJECT_SOURCES}
                  )
              # Define target properties for Android with Qt 6 as:
              #    set_property(TARGET video-player APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
              #                 ${CMAKE_CURRENT_SOURCE_DIR}/android)
              # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
              else()
                  if(ANDROID)
                      add_library(video-player SHARED
                          ${PROJECT_SOURCES}
                      )
              # Define properties for Android with Qt 5 after find_package() calls as:
              #    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
                  else()
                      add_executable(video-player
                          ${PROJECT_SOURCES}
                      )
                  endif()
              endif()
              
              target_link_libraries(video-player PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
              
              set_target_properties(video-player PROPERTIES
                  MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
                  MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
                  MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
                  MACOSX_BUNDLE TRUE
                  WIN32_EXECUTABLE TRUE
              )
              
              if(QT_VERSION_MAJOR EQUAL 6)
                  qt_finalize_executable(video-player)
              endif()
              
              

              And I am using this class widget inside a layout of another widget

              Thank you

              JonBJ Christian EhrlicherC 2 Replies Last reply
              0
              • Y yegender

                Here is the code:

                Header:

                #ifndef YOUTUBETOPBAR_H
                #define YOUTUBETOPBAR_H
                
                #include <QWidget>
                #include <QVBoxLayout>
                #include <QHBoxLayout>
                #include <QLabel>
                #include <QLineEdit>
                #include <QToolButton>
                #include <QObject>
                class YoutubeTopBar : public QWidget
                {
                    Q_OBJECT
                public:
                    explicit YoutubeTopBar(QWidget *parent = nullptr);
                    QHBoxLayout mainLayout;
                    QToolButton ToogleLeftPane;
                    QToolButton YoutubeHome;
                    QToolButton ToogleDownloadManager;
                    QToolButton ToogleSettings;
                    QLineEdit Search;
                
                
                public slots:
                    void ChangeSearchStyleSheet();
                signals:
                
                };
                
                #endif // YOUTUBELEFTPANE_H
                
                

                Source File:

                #include "youtubetopbar.h"
                
                YoutubeTopBar::YoutubeTopBar(QWidget *parent)
                    : QWidget{parent}
                {
                    this->setWindowTitle("YT Top Bar");
                    this->setLayout(&mainLayout);
                    mainLayout.setMargin(0);
                    mainLayout.setSpacing(0);
                
                    mainLayout.addWidget(&ToogleLeftPane);
                    mainLayout.addWidget(&YoutubeHome);
                    mainLayout.addWidget(&Search);
                    mainLayout.addWidget(&ToogleDownloadManager);
                    mainLayout.addWidget(&ToogleSettings);
                
                    ToogleLeftPane.setText("Toogle Left Pane");
                    ToogleLeftPane.setStyleSheet("QToolButton{"
                                                 "background-color:rgba(0,0,0,0.6);"
                                                 "color:white;"
                                                 "border:none;"
                                                 "margin:5px;"
                                                 "padding:10px;"
                                                 "}"
                                                 "QToolButton::hover{"
                                                 "background-color:rgba(255,255,255,0.1);"
                                                 "border-radius:5px;"
                                                 "}");
                    YoutubeHome.setText("Youtube");
                    YoutubeHome.setStyleSheet("QToolButton{"
                                              "background-color:rgba(0,0,0,0.6);"
                                              "color:white;"
                                              "border:none;"
                                              "margin:5px;"
                                              "padding:10px;"
                                              "}"
                                              "QToolButton::hover{"
                                              "background-color:rgba(255,255,255,0.1);"
                                              "border-radius:5px;"
                                              "}");
                    ToogleSettings.setText("Settings");
                    ToogleSettings.setStyleSheet("QToolButton{"
                                                 "background-color:rgba(0,0,0,0.6);"
                                                 "color:white;"
                                                 "border:none;"
                                                 "margin:5px;"
                                                 "padding:10px;"
                                                 "}"
                                                 "QToolButton::hover{"
                                                 "background-color:rgba(255,255,255,0.1);"
                                                 "border-radius:5px;"
                                                 "}");
                    ToogleDownloadManager.setText("Download Manager");
                    ToogleDownloadManager.setStyleSheet("QToolButton{"
                                                        "background-color:rgba(0,0,0,0.6);"
                                                        "color:white;"
                                                        "border:none;"
                                                        "margin:5px;"
                                                        "padding:10px;"
                                                        "}"
                                                        "QToolButton::hover{"
                                                        "background-color:rgba(255,255,255,0.1);"
                                                        "border-radius:5px;"
                                                        "}");
                    Search.setPlaceholderText("Search");
                    Search.setStyleSheet("QLineEdit{"
                                         "background-color:rgba(0,0,0,0.3);"
                                         "border:none;"
                                         "margin:5px;"
                                         "padding:10px;"
                                         "border-radius:5px;"
                                         "}"
                                         "QLineEdit::hover{"
                                         "background-color:rgba(255,255,255,0.1);"
                                         "border-radius:5px;"
                                         "}");
                
                    QObject::connect(Search, &QLineEdit::textChanged),this,&YoutubeTopBar::ChangeSearchStyleSheet);
                }
                
                void YoutubeTopBar::ChangeSearchStyleSheet(){
                    if(Search.text().isEmpty()){
                        Search.setStyleSheet("color:rgba(255,255,255,0.6);");
                    } else {
                        Search.setStyleSheet("color:white;");
                    }
                }
                
                

                CMAKE:

                cmake_minimum_required(VERSION 3.5)
                
                project(video-player VERSION 0.1 LANGUAGES CXX)
                
                set(CMAKE_INCLUDE_CURRENT_DIR ON)
                
                set(CMAKE_AUTOUIC ON)
                set(CMAKE_AUTOMOC ON)
                set(CMAKE_AUTORCC ON)
                
                set(CMAKE_CXX_STANDARD 17)
                set(CMAKE_CXX_STANDARD_REQUIRED ON)
                
                find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
                find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
                
                set(PROJECT_SOURCES
                        main.cpp
                        mainwindow.cpp mainwindow.h
                        youtubeleftpane.h youtubeleftpane.cpp
                        youtubetopbar.h youtubetopbar.cpp
                        youtubebanner.h youtubebanner.cpp
                        youtubepage.h youtubepage.cpp
                        youtubetopbarwrapper.h youtubetopbarwrapper.cpp
                )
                
                if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
                    qt_add_executable(video-player
                        MANUAL_FINALIZATION
                        ${PROJECT_SOURCES}
                    )
                # Define target properties for Android with Qt 6 as:
                #    set_property(TARGET video-player APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
                #                 ${CMAKE_CURRENT_SOURCE_DIR}/android)
                # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
                else()
                    if(ANDROID)
                        add_library(video-player SHARED
                            ${PROJECT_SOURCES}
                        )
                # Define properties for Android with Qt 5 after find_package() calls as:
                #    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
                    else()
                        add_executable(video-player
                            ${PROJECT_SOURCES}
                        )
                    endif()
                endif()
                
                target_link_libraries(video-player PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
                
                set_target_properties(video-player PROPERTIES
                    MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
                    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
                    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
                    MACOSX_BUNDLE TRUE
                    WIN32_EXECUTABLE TRUE
                )
                
                if(QT_VERSION_MAJOR EQUAL 6)
                    qt_finalize_executable(video-player)
                endif()
                
                

                And I am using this class widget inside a layout of another widget

                Thank you

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #7

                @yegender said in Error in connecting Signals and slots qt6 lineEdit:

                QObject::connect(Search, &QLineEdit::textChanged),this,&YoutubeTopBar::ChangeSearchStyleSheet);

                Please just count your parentheses or copy/paste what was suggested to you, nobody wrote the above. Hence the error message.

                Y 1 Reply Last reply
                0
                • Y yegender

                  Here is the code:

                  Header:

                  #ifndef YOUTUBETOPBAR_H
                  #define YOUTUBETOPBAR_H
                  
                  #include <QWidget>
                  #include <QVBoxLayout>
                  #include <QHBoxLayout>
                  #include <QLabel>
                  #include <QLineEdit>
                  #include <QToolButton>
                  #include <QObject>
                  class YoutubeTopBar : public QWidget
                  {
                      Q_OBJECT
                  public:
                      explicit YoutubeTopBar(QWidget *parent = nullptr);
                      QHBoxLayout mainLayout;
                      QToolButton ToogleLeftPane;
                      QToolButton YoutubeHome;
                      QToolButton ToogleDownloadManager;
                      QToolButton ToogleSettings;
                      QLineEdit Search;
                  
                  
                  public slots:
                      void ChangeSearchStyleSheet();
                  signals:
                  
                  };
                  
                  #endif // YOUTUBELEFTPANE_H
                  
                  

                  Source File:

                  #include "youtubetopbar.h"
                  
                  YoutubeTopBar::YoutubeTopBar(QWidget *parent)
                      : QWidget{parent}
                  {
                      this->setWindowTitle("YT Top Bar");
                      this->setLayout(&mainLayout);
                      mainLayout.setMargin(0);
                      mainLayout.setSpacing(0);
                  
                      mainLayout.addWidget(&ToogleLeftPane);
                      mainLayout.addWidget(&YoutubeHome);
                      mainLayout.addWidget(&Search);
                      mainLayout.addWidget(&ToogleDownloadManager);
                      mainLayout.addWidget(&ToogleSettings);
                  
                      ToogleLeftPane.setText("Toogle Left Pane");
                      ToogleLeftPane.setStyleSheet("QToolButton{"
                                                   "background-color:rgba(0,0,0,0.6);"
                                                   "color:white;"
                                                   "border:none;"
                                                   "margin:5px;"
                                                   "padding:10px;"
                                                   "}"
                                                   "QToolButton::hover{"
                                                   "background-color:rgba(255,255,255,0.1);"
                                                   "border-radius:5px;"
                                                   "}");
                      YoutubeHome.setText("Youtube");
                      YoutubeHome.setStyleSheet("QToolButton{"
                                                "background-color:rgba(0,0,0,0.6);"
                                                "color:white;"
                                                "border:none;"
                                                "margin:5px;"
                                                "padding:10px;"
                                                "}"
                                                "QToolButton::hover{"
                                                "background-color:rgba(255,255,255,0.1);"
                                                "border-radius:5px;"
                                                "}");
                      ToogleSettings.setText("Settings");
                      ToogleSettings.setStyleSheet("QToolButton{"
                                                   "background-color:rgba(0,0,0,0.6);"
                                                   "color:white;"
                                                   "border:none;"
                                                   "margin:5px;"
                                                   "padding:10px;"
                                                   "}"
                                                   "QToolButton::hover{"
                                                   "background-color:rgba(255,255,255,0.1);"
                                                   "border-radius:5px;"
                                                   "}");
                      ToogleDownloadManager.setText("Download Manager");
                      ToogleDownloadManager.setStyleSheet("QToolButton{"
                                                          "background-color:rgba(0,0,0,0.6);"
                                                          "color:white;"
                                                          "border:none;"
                                                          "margin:5px;"
                                                          "padding:10px;"
                                                          "}"
                                                          "QToolButton::hover{"
                                                          "background-color:rgba(255,255,255,0.1);"
                                                          "border-radius:5px;"
                                                          "}");
                      Search.setPlaceholderText("Search");
                      Search.setStyleSheet("QLineEdit{"
                                           "background-color:rgba(0,0,0,0.3);"
                                           "border:none;"
                                           "margin:5px;"
                                           "padding:10px;"
                                           "border-radius:5px;"
                                           "}"
                                           "QLineEdit::hover{"
                                           "background-color:rgba(255,255,255,0.1);"
                                           "border-radius:5px;"
                                           "}");
                  
                      QObject::connect(Search, &QLineEdit::textChanged),this,&YoutubeTopBar::ChangeSearchStyleSheet);
                  }
                  
                  void YoutubeTopBar::ChangeSearchStyleSheet(){
                      if(Search.text().isEmpty()){
                          Search.setStyleSheet("color:rgba(255,255,255,0.6);");
                      } else {
                          Search.setStyleSheet("color:white;");
                      }
                  }
                  
                  

                  CMAKE:

                  cmake_minimum_required(VERSION 3.5)
                  
                  project(video-player VERSION 0.1 LANGUAGES CXX)
                  
                  set(CMAKE_INCLUDE_CURRENT_DIR ON)
                  
                  set(CMAKE_AUTOUIC ON)
                  set(CMAKE_AUTOMOC ON)
                  set(CMAKE_AUTORCC ON)
                  
                  set(CMAKE_CXX_STANDARD 17)
                  set(CMAKE_CXX_STANDARD_REQUIRED ON)
                  
                  find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
                  find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
                  
                  set(PROJECT_SOURCES
                          main.cpp
                          mainwindow.cpp mainwindow.h
                          youtubeleftpane.h youtubeleftpane.cpp
                          youtubetopbar.h youtubetopbar.cpp
                          youtubebanner.h youtubebanner.cpp
                          youtubepage.h youtubepage.cpp
                          youtubetopbarwrapper.h youtubetopbarwrapper.cpp
                  )
                  
                  if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
                      qt_add_executable(video-player
                          MANUAL_FINALIZATION
                          ${PROJECT_SOURCES}
                      )
                  # Define target properties for Android with Qt 6 as:
                  #    set_property(TARGET video-player APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
                  #                 ${CMAKE_CURRENT_SOURCE_DIR}/android)
                  # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
                  else()
                      if(ANDROID)
                          add_library(video-player SHARED
                              ${PROJECT_SOURCES}
                          )
                  # Define properties for Android with Qt 5 after find_package() calls as:
                  #    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
                      else()
                          add_executable(video-player
                              ${PROJECT_SOURCES}
                          )
                      endif()
                  endif()
                  
                  target_link_libraries(video-player PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
                  
                  set_target_properties(video-player PROPERTIES
                      MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
                      MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
                      MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
                      MACOSX_BUNDLE TRUE
                      WIN32_EXECUTABLE TRUE
                  )
                  
                  if(QT_VERSION_MAJOR EQUAL 6)
                      qt_finalize_executable(video-player)
                  endif()
                  
                  

                  And I am using this class widget inside a layout of another widget

                  Thank you

                  Christian EhrlicherC Online
                  Christian EhrlicherC Online
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @yegender said in Error in connecting Signals and slots qt6 lineEdit:

                  QObject::connect(Search, &QLineEdit::textChanged),this,&YoutubeTopBar::ChangeSearchStyleSheet);

                  This does not even compile...

                  Also please create objects on the heap instead adding them as objects in your class - it will most likely crash when the YoutubeTopBar object gets destroyed since then the children are beeing deleted automatically which will not work in your case - see QObject Trees and Ownership.

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  1 Reply Last reply
                  1
                  • JonBJ JonB

                    @yegender said in Error in connecting Signals and slots qt6 lineEdit:

                    QObject::connect(Search, &QLineEdit::textChanged),this,&YoutubeTopBar::ChangeSearchStyleSheet);

                    Please just count your parentheses or copy/paste what was suggested to you, nobody wrote the above. Hence the error message.

                    Y Offline
                    Y Offline
                    yegender
                    wrote on last edited by
                    #9

                    @JonB Same error

                    Christian EhrlicherC JonBJ 2 Replies Last reply
                    0
                    • Y yegender

                      @JonB Same error

                      Christian EhrlicherC Online
                      Christian EhrlicherC Online
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @yegender said in Error in connecting Signals and slots qt6 lineEdit:

                      @JonB Same error

                      What error? Fix your code and post your real code + compiler error.

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      1 Reply Last reply
                      0
                      • Y yegender

                        @JonB Same error

                        JonBJ Offline
                        JonBJ Offline
                        JonB
                        wrote on last edited by
                        #11

                        @yegender
                        Then you have something else wrong. People cannot help if we do not have the exact line copied and pasted from your live code, together with the text of the error message. All copied for 100% certain.

                        1 Reply Last reply
                        0
                        • Y Offline
                          Y Offline
                          yegender
                          wrote on last edited by yegender
                          #12

                          This is the exact Line I have copied
                          f3ab3ac5-1b94-49f2-b815-6ccd6e624f25-image.png

                          1 Reply Last reply
                          0
                          • Christian EhrlicherC Online
                            Christian EhrlicherC Online
                            Christian Ehrlicher
                            Lifetime Qt Champion
                            wrote on last edited by Christian Ehrlicher
                            #13

                            Because Search is an object, not a pointer - pass a pointer because QObject::connect() wants pointers.

                            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                            Visit the Qt Academy at https://academy.qt.io/catalog

                            1 Reply Last reply
                            1
                            • Y Offline
                              Y Offline
                              yegender
                              wrote on last edited by
                              #14

                              Thank you, now I got why actually mostly pointers are used.

                              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