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. Private slots issue [solved]
Qt 6.11 is out! See what's new in the release blog

Private slots issue [solved]

Scheduled Pinned Locked Moved General and Desktop
15 Posts 4 Posters 8.7k Views 1 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.
  • S Offline
    S Offline
    Soraltan
    wrote on last edited by
    #6

    Hi,

    just to be sure: The class to which you added the private slots inherits from QObject (maybe indirectly) and has the Q_OBJECT macro?!? I mean the class itself, not only its parents?!?

    I admit, the compiler errors don't really fit. But I wouldn't exclude the possibility that in a special situation these compiler error still occur. And it would be kind of the typical solution when you encounter problems as soon as you add signals and/or slots to your class.

    Best Soraltan

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SahamGhazavi
      wrote on last edited by
      #7

      Hi

      Yes, I do have the following
      @
      class finddialog : public QDialog
      {
      Q_OBJECT
      ...
      @

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Soraltan
        wrote on last edited by
        #8

        Ok, so my guess is off the table. From what you have given us so far, I have no clue.

        What happens, when you add the same function under public slots:? Does it compile then?

        Could you give use the code and more of the compiler output?

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          qxoz
          wrote on last edited by
          #9

          "Here":https://github.com/mutse/qt5-book-code you can find examples for this book written on Qt5

          1 Reply Last reply
          0
          • JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by
            #10

            Hmm, odd.

            Ok, do this:

            Open Qt Creator

            Select File -> New File or Project... -> Applications -> Qt Widgets Application (and then keep the default settings)

            Select Build -> Run

            What do you get?

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SahamGhazavi
              wrote on last edited by
              #11

              Hi JKSH

              It runs fine. Simply a blank form :)

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SahamGhazavi
                wrote on last edited by
                #12

                Hi Soraltan

                Here are the complete code:

                find.pro:
                @
                #-------------------------------------------------

                Project created by QtCreator 2014-04-30T23:08:06

                #-------------------------------------------------

                QT += core gui

                greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

                TARGET = find
                TEMPLATE = app

                SOURCES += main.cpp
                finddialog.cpp

                HEADERS += finddialog.h

                FORMS += finddialog.ui

                @
                finddialog.h:
                @
                #ifndef FINDDIALOG_H
                #define FINDDIALOG_H

                #include <QDialog>
                #include <QLabel>
                #include <QPushButton>
                #include <QLineEdit>
                #include <QCheckBox>
                #include <QWidget>
                #include <QHBoxLayout>

                namespace Ui {
                class finddialog;
                }

                class finddialog : public QDialog
                {
                Q_OBJECT

                public:
                explicit finddialog(QWidget *parent = 0);
                ~finddialog();
                signals:
                void findNext(const QString &str,Qt::CaseSensitivity cs);
                void findPrevious(const QString & str,Qt::CaseSensitivity cs) ;
                private slots:

                void findClicked();
                void enableFindButton(const QString &text);
                private:
                Ui::finddialog *ui;
                QLabel label;
                QLineEdit lineEdit;
                QCheckBox
                caseCheckBox;
                QCheckBox
                backwardCheckBox;
                QPushButton *findButton;
                QPushButton *closeButton;
                QHBoxLayout *HLayout;

                };

                #endif // FINDDIALOG_H

                @

                finddialog.cpp:
                @
                #include "finddialog.h"
                #include "ui_finddialog.h"

                finddialog::finddialog(QWidget *parent) :
                QDialog(parent),
                ui(new Ui::finddialog)
                {

                ui->setupUi(this);

                }

                finddialog::~finddialog()
                {
                delete ui;
                }

                @

                and main.cpp:

                @
                #include "finddialog.h"
                #include <QApplication>

                int main(int argc, char *argv[])
                {
                QApplication a(argc, argv);
                finddialog w;
                w.show();

                return a.exec();
                }

                @

                Do these help?

                Thanks

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  Soraltan
                  wrote on last edited by
                  #13

                  Hi,

                  so looking at your code, here seem to be two private slots declared in the .h. Wehn you remove these the code compiles, when you add these the compiler complains, right?

                  But there seems to be no definition in the .cpp file! This is probably what the linker complains about.

                  Add a (even empty) definition for those in the .cpp file should help E.g.

                  @
                  void finddialog::findClicked(){
                  }

                  void finddialog::enableFindButton(const QString &text){
                  }
                  @
                  Does that solve it?!?

                  Best Soraltan

                  1 Reply Last reply
                  1
                  • S Offline
                    S Offline
                    SahamGhazavi
                    wrote on last edited by
                    #14

                    Hi Soraltan

                    That fixed the issue. It's coming from my habit to run/compile as soon as I write one function. I did continue when I got the error ;)

                    Thank you

                    P.S. You will be my point of contact for future. I had asked this question in many places even on Faceboook. People tried really hard to help me but you got it right :)

                    1 Reply Last reply
                    1
                    • S Offline
                      S Offline
                      Soraltan
                      wrote on last edited by
                      #15

                      Glad we found it.

                      Please mark the thread a solved by prepending a [solved] in the title.

                      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