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. Qt creater SIGNAL question
Forum Updated to NodeBB v4.3 + New Features

Qt creater SIGNAL question

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 3.2k 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.
  • A Offline
    A Offline
    ahura_24
    wrote on last edited by
    #1

    hi every body . i have one question . why some times in qt creator doesnt display all signal of one object ? is that one bug in creator ?
    for example 'QStandardItemModel' does have about 20 signals but in qt creator when i write
    @ QObject::connect(model, SINGAL(.... @ display about 6 signals of 'QStandardItemModel' ! i see this problem for QStateMachine and report it.
    tnx for help

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ahura_24
      wrote on last edited by
      #2

      now 'modelReset()' one signal of model and works ! but doesnt display to list of SIGNAL() !

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

        Look at the documentation of those signals (http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#signals ) -- many of them say:

        bq. It can only be emitted by the QAbstractItemModel implementation, and cannot be explicitly emitted in subclass code.

        Those signals are private and can only be emitted by QAbstractItemModel. They are not displayed in QtCreator because QStandardItemModel is not allowed to emit them.

        [quote author="ahura_24" date="1344118300"]now 'modelReset()' one signal of model and works ![/quote]

        That's interesting! modelReset() is supposed to be one of the private signals, according to the source code (http://qt.gitorious.org/qt/qt/blobs/4.8/src/corelib/kernel/qabstractitemmodel.h ). Can you show us your code where you tested modelReset()? How does it work?

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

        1 Reply Last reply
        0
        • A Offline
          A Offline
          ahura_24
          wrote on last edited by
          #4

          @
          int main(int argc, char **argv)
          {
          QApplication app(argc, argv);

          QStandardItemModel m;
          QLabel l("asdfasdf");
          
          QObject::connect(&m, SIGNAL(modelReset()), &l, SLOT(clear()));
          
          
          l.show();
          m.clear();
          
          
          
          return app.exec();
          

          }
          @

          in debug mode if signal or slot doesnt exist show warning message but in this code doesnt display warning and works correctly .

          how can i define private signals ?
          if these signals are private , why in assistant write 18 signals 'inherit' from QAbstractItemModel ?
          private member doesnt inherit in 'public inheritance' !

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

            Ah, sorry... I was mistaken earlier. There's no such thing as a "private signal" -- all signals are publicly visible.

            What's happening is: Subclasses of QAbstractItemModel are not allowed to EXPLICITLY emit some of the inherited signals, which means that subclass code must not contain "emit columnsAboutToBeChanged()". If the subclass wants to emit those signals, it must call QAbstractItemModel's protected functions, e.g.

            @
            MyModel : public QAbstractItemModel
            {
            // ...

            void wrongFunction() {
                emit columnsAboutToBeInserted(); // DISALLOWED
            
                // ...
                // Code to insert columns
            }
            
            void correctFunction() {
                beginInsertColumns(); // This function is inherited from QAbstractItem model, and will emit columnsAboutToBeInserted()
            
                // ...
                // Code to insert columns
            
                endInsertColumns();
            }
            

            };
            @

            If I try to compile the code above, my compiler will complain in line #6 that columnsAboutToBeInserted() is private. But, the signals are not really private: my model must still emit the signal before inserting data, so that my application can prepare properly.

            So, we have an answer to your original post: Those signals are marked as "private" to prevent wrong code from compiling (like my example above). But, that approach made QtCreator consider them private functions, and hide them from the list of available signals.

            I guess QtCreator SHOULD display those signals. Do you want to file a bug report?

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

            1 Reply Last reply
            0
            • A Offline
              A Offline
              ahura_24
              wrote on last edited by
              #6

              yes i report this bug.
              i have another question . why in some class we have 'setTextAlignment' and some other class 'setAlignment' ?
              for example in 'QLabel' has 'setAlignment' but 'QTableWidgetItem' has 'setTextAlignment' ! it create one inconsistency for name of functions !!

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

                http://qt-project.org/doc/qt-4.8/qtablewidgetitem.html
                http://qt-project.org/doc/qt-4.8/qlabel.html

                QTableItemWidgetItem::setTextAlignment() controls text only.
                QLabel::setAlignment() controls text or images or movies.

                They have different functions, so they have different names.

                By the way, if you have a new question, it's good to start a new topic so that other people who are interested can find it :)

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

                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