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]

Private slots issue [solved]

Scheduled Pinned Locked Moved General and Desktop
15 Posts 4 Posters 5.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.
  • JKSHJ Offline
    JKSHJ Offline
    JKSH
    Moderators
    wrote on last edited by
    #4

    Oops, I just noticed:
    [quote author="Saham" date="1400279338"]
    Qt Creator 3.0.1
    Based on Qt 5.2.1(Clang 5.0 (Apple), 64 bit)[/quote]That is the version information for Qt Creator. But, what is your version of Qt? (Qt Creator is NOT Qt)

    Open Tools -> Options -> Build & Run -> Kits -- what do you see there? Did you download 32-bit Qt or 64-bit Qt?

    Also, can you please post your .pro file here?

    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
      #5

      I am using 64 on mac. The Kit is auto-detected:
      Name:
      Desktop Qt 5.2.1 clang 64bit
      Device:
      Run locally(default for Desktop)
      bCompiler:
      Clang(x84 64bin in /usr/bin)
      Debugger:
      System LLDB at usr/bin/lib
      Qt 5.2.1 Clang 64bit

      and here is the .pro file
      @

      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
      @

      Thank you :)

      1 Reply Last reply
      0
      • 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