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. Problem with slots
Forum Updated to NodeBB v4.3 + New Features

Problem with slots

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 3.3k 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.
  • K Offline
    K Offline
    kitten
    wrote on last edited by
    #1

    hi to every one
    i have a mainwindow class that inherited from qmainwindow
    and i have another class named class2 that inherited from qdialog;
    and in my mainwindow class i redefine my class2 with this code
    class2 en = new class2(this);
    on class2 i have a qpushbutton named button1;
    i wrote this code in my class2 constructor to use slot

    @
    connect(ui.button1,SIGNAL(clicked()),this,SLOT(this->adddatabase()));
    @

    and i add adddatabase() function to my private slots
    but when i click on button1 it does'nt run adddatabase() function
    what is my problem?

    [EDIT: code formatting, please wrap in @-tags, Volker]

    www.kitten.mihanblog.com

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      remove "this->" from the SLOT():

      @
      connect(ui.button1, SIGNAL(clicked()), this, SLOT(adddatabase()));
      @

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mrtc3
        wrote on last edited by
        #3

        to late ;)

        <how can I delete posts?>

        There are 10 types. Those who understand binary and those who don't .)

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          [quote author="mrtc3" date="1312892166"]to late ;)

          <how can I delete posts?>[/quote]

          I don't know if that's possible for non-moderators.

          Anyways, it does not hurt to have doubled answers. I consider it an advantage and a proof of an active community :-)

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kitten
            wrote on last edited by
            #5

            i remove this but it does'nt change anything and my aadddatabase() function does'nt run

            www.kitten.mihanblog.com

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mrtc3
              wrote on last edited by
              #6

              [quote author="Volker" date="1312892535"]I consider it an advantage and a proof of an active community :-)[/quote]
              So answers are welcome, and I can train my Qt skills ;)

              kitten: adddatabase() must be declared as a slot in your header file.

              @
              private slots:
              void adddatabase();
              @
              and if its derived from QDialog the Q_OBJECT macro should be set.

              There are 10 types. Those who understand binary and those who don't .)

              1 Reply Last reply
              0
              • K Offline
                K Offline
                kitten
                wrote on last edited by
                #7

                when i add Q_Object macro on my project it get me this eror:
                1>------ Build started: Project: finger, Configuration: Debug Win32 ------
                1>Moc'ing enroll.h...
                1>moc: Too many input files specified
                1>Usage: moc [options] <header-file>
                1> -o<file> write output to file rather than stdout
                1> -I<dir> add dir to the include path for header files
                1> -E preprocess only; do not generate meta object code
                1> -D<macro>[=<def>] define macro, with optional definition
                1> -U<macro> undefine macro
                1> -i do not generate an #include statement
                1> -p<path> path prefix for included file
                1> -f[<file>] force #include, optional file name
                1> -nw do not display warnings
                1> @<file> read additional options from file
                1> -v display version of moc
                1>Project : error PRJ0019: A tool returned an error code from "Moc'ing enroll.h..."
                1>Build log was saved at "file://c:\Users\sazgar\Documents\Visual Studio 2008\Projects\finger\finger\Debug\BuildLog.htm"
                1>finger - 1 error(s), 0 warning(s)
                ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

                www.kitten.mihanblog.com

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mrtc3
                  wrote on last edited by
                  #8

                  I guess "this":http://developer.qt.nokia.com/forums/viewthread/1951I is wide spread: moc it manually again "moc.exe enroll.h -o moc_enroll.cxx" and add that *.cxx to your project (Add --> Existing Item..). This worked when I had this problem.

                  There are 10 types. Those who understand binary and those who don't .)

                  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