Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Edit QtDesigner "connect" - is it possible ?
Qt 6.11 is out! See what's new in the release blog

Edit QtDesigner "connect" - is it possible ?

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
8 Posts 3 Posters 1.7k Views 3 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
    Anonymous_Banned275
    wrote on last edited by
    #1

    I believe this has been asked before and do not recall how it was answered.
    If it was "solved" or not , would it be OK to discuss the subject again?
    QtDesigner Edit ->Edit Widgets "go to slot.." seems to build part of the "signal" . In my view "pushing a button " is an event , in Qt terminology it is a event called signal . ( Please correct me if I am wrong here.)
    This part actually creates editable code , however , it seems to confuse the issue by mixing event / signal with actual function performed by the signal. It does not look anything related to "connect".

    QtDesigner Edit ->Edit Signals/Slots nicely "connect" two wiglets using GUI.
    Works great if the action on destination widget is simple - such as "clear()".

    However, this very useful and intuitive GUI stops being user friendly when the action on destination widget gets more complex - such as illustrated bellow.

    I do realize it is cluttered so I am including partial views and its description.

    First line in Signal / slot editor function is to fill the "list" using
    "doitemsLayout". Works as expected.

    My simple question is
    where is the actual C++ code performing this doitemsLayout function ?

    108a1a77-a300-4659-bcfd-2703b6774c25-image.png

    My next objective is to click on item in the " list " and copy the item to "list_2" using QtDesigner .

    Neither of the "connect" attempted do this.
    Including list to list_2.

    ad65d96a-8e84-4853-9880-f0e42018c6f0-image.png

    This boils down to two basic questions:
    is Qt Designer limited to actions likes clear() only ? By design?

    Is there any way to physically see the "connect" function ( both SIGNAL and SLOT as build by QtDesigner , then debug and edit it - especially the function ?

    7c0f82e7-9e48-43a5-98f7-efa80fcde24d-image.png f2c0f9e1-ab5e-4862-bee7-af5b4ccf458a-image.png

    Pl45m4P A 2 Replies Last reply
    0
    • A Anonymous_Banned275

      I believe this has been asked before and do not recall how it was answered.
      If it was "solved" or not , would it be OK to discuss the subject again?
      QtDesigner Edit ->Edit Widgets "go to slot.." seems to build part of the "signal" . In my view "pushing a button " is an event , in Qt terminology it is a event called signal . ( Please correct me if I am wrong here.)
      This part actually creates editable code , however , it seems to confuse the issue by mixing event / signal with actual function performed by the signal. It does not look anything related to "connect".

      QtDesigner Edit ->Edit Signals/Slots nicely "connect" two wiglets using GUI.
      Works great if the action on destination widget is simple - such as "clear()".

      However, this very useful and intuitive GUI stops being user friendly when the action on destination widget gets more complex - such as illustrated bellow.

      I do realize it is cluttered so I am including partial views and its description.

      First line in Signal / slot editor function is to fill the "list" using
      "doitemsLayout". Works as expected.

      My simple question is
      where is the actual C++ code performing this doitemsLayout function ?

      108a1a77-a300-4659-bcfd-2703b6774c25-image.png

      My next objective is to click on item in the " list " and copy the item to "list_2" using QtDesigner .

      Neither of the "connect" attempted do this.
      Including list to list_2.

      ad65d96a-8e84-4853-9880-f0e42018c6f0-image.png

      This boils down to two basic questions:
      is Qt Designer limited to actions likes clear() only ? By design?

      Is there any way to physically see the "connect" function ( both SIGNAL and SLOT as build by QtDesigner , then debug and edit it - especially the function ?

      7c0f82e7-9e48-43a5-98f7-efa80fcde24d-image.png f2c0f9e1-ab5e-4862-bee7-af5b4ccf458a-image.png

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @AnneRanch said in Edit QtDesigner "connect" - is it possible ?:

      My simple question is
      where is the actual C++ code performing this doitemsLayout function ?

      In your ListWidget.cpp file or wherever your list was defined.

      is Qt Designer limited to actions likes clear() only ? By design?

      Yes, QtDesigner is very limited. If you want to pass items around, you'll need to do that in your code.

      Is there any way to physically see the "connect" function ( both SIGNAL and SLOT as build by QtDesigner , then debug and edit it - especially the function ?

      QtDesigner only sets up the connection. The real code is still in your code file or in the Qt source when using "standard" slots like QWidget::close().

      But you can check your connection in your .ui file. The designer is only the graphical representation of this XML ui file.
      You can't debug in design mode. Only when debugging your source code, you will see what's going on.

      QtDesigner doent "build" anything. The "Edit Signals & Slots" function in QtD is a replacement for, e.g.

      connect(ui->listWidget, &QListWidget::itemClicked, ui->plainTextEdit, &QPlainTextEdit::copy);
      

      Nothing more, nothing less.
      And, btw, this connection doesnt make sense at all :)

      If you really want to send your item or item properties to some other widget (display the item name in textEdit, or whatever), you have to do it by coding the signal slot connection in your cpp / h.

      This is how your QtDesigner connections look like in your ui file. This is all what QtDesigner does.
      signal_slot.png


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      A 1 Reply Last reply
      2
      • A Anonymous_Banned275

        I believe this has been asked before and do not recall how it was answered.
        If it was "solved" or not , would it be OK to discuss the subject again?
        QtDesigner Edit ->Edit Widgets "go to slot.." seems to build part of the "signal" . In my view "pushing a button " is an event , in Qt terminology it is a event called signal . ( Please correct me if I am wrong here.)
        This part actually creates editable code , however , it seems to confuse the issue by mixing event / signal with actual function performed by the signal. It does not look anything related to "connect".

        QtDesigner Edit ->Edit Signals/Slots nicely "connect" two wiglets using GUI.
        Works great if the action on destination widget is simple - such as "clear()".

        However, this very useful and intuitive GUI stops being user friendly when the action on destination widget gets more complex - such as illustrated bellow.

        I do realize it is cluttered so I am including partial views and its description.

        First line in Signal / slot editor function is to fill the "list" using
        "doitemsLayout". Works as expected.

        My simple question is
        where is the actual C++ code performing this doitemsLayout function ?

        108a1a77-a300-4659-bcfd-2703b6774c25-image.png

        My next objective is to click on item in the " list " and copy the item to "list_2" using QtDesigner .

        Neither of the "connect" attempted do this.
        Including list to list_2.

        ad65d96a-8e84-4853-9880-f0e42018c6f0-image.png

        This boils down to two basic questions:
        is Qt Designer limited to actions likes clear() only ? By design?

        Is there any way to physically see the "connect" function ( both SIGNAL and SLOT as build by QtDesigner , then debug and edit it - especially the function ?

        7c0f82e7-9e48-43a5-98f7-efa80fcde24d-image.png f2c0f9e1-ab5e-4862-bee7-af5b4ccf458a-image.png

        A Offline
        A Offline
        Anonymous_Banned275
        wrote on last edited by
        #3

        @AnneRanch
        I am not sure if this post is appropriate , but I am really looking for somebody who will participate in discussion.

        I have QtDesigner "connect" sort of working for ONE case .

        What is puzzling is this

        1. the "list" gets filled by other action - with three "items".

        2. the "connect" - third line in attached screen shot - fills/ copy ONLY one item. The objective is to copy all items.

        3. As expected - clicking / selecting an item in "list" adds it to "plaintextEdit_2"

        4. Only "list" and "plaintextEdit" gives option to "appendPlainText" hence "copy" QString to QString .
          Makes sense, but I like to see copy all "items" not a single string .

        My guess is the text widgets contents ( string or item ) should match - but the widget titles are misleading.

        Sorry for being persistent - back to experimenting.

        8d68406c-f17c-425b-bd11-c44f5d4cbf79-image.png

        Pl45m4P 1 Reply Last reply
        0
        • Pl45m4P Pl45m4

          @AnneRanch said in Edit QtDesigner "connect" - is it possible ?:

          My simple question is
          where is the actual C++ code performing this doitemsLayout function ?

          In your ListWidget.cpp file or wherever your list was defined.

          is Qt Designer limited to actions likes clear() only ? By design?

          Yes, QtDesigner is very limited. If you want to pass items around, you'll need to do that in your code.

          Is there any way to physically see the "connect" function ( both SIGNAL and SLOT as build by QtDesigner , then debug and edit it - especially the function ?

          QtDesigner only sets up the connection. The real code is still in your code file or in the Qt source when using "standard" slots like QWidget::close().

          But you can check your connection in your .ui file. The designer is only the graphical representation of this XML ui file.
          You can't debug in design mode. Only when debugging your source code, you will see what's going on.

          QtDesigner doent "build" anything. The "Edit Signals & Slots" function in QtD is a replacement for, e.g.

          connect(ui->listWidget, &QListWidget::itemClicked, ui->plainTextEdit, &QPlainTextEdit::copy);
          

          Nothing more, nothing less.
          And, btw, this connection doesnt make sense at all :)

          If you really want to send your item or item properties to some other widget (display the item name in textEdit, or whatever), you have to do it by coding the signal slot connection in your cpp / h.

          This is how your QtDesigner connections look like in your ui file. This is all what QtDesigner does.
          signal_slot.png

          A Offline
          A Offline
          Anonymous_Banned275
          wrote on last edited by
          #4

          @Pl45m4 Sorry, we "doubled". I was typing when you posted.

          1 Reply Last reply
          0
          • A Anonymous_Banned275

            @AnneRanch
            I am not sure if this post is appropriate , but I am really looking for somebody who will participate in discussion.

            I have QtDesigner "connect" sort of working for ONE case .

            What is puzzling is this

            1. the "list" gets filled by other action - with three "items".

            2. the "connect" - third line in attached screen shot - fills/ copy ONLY one item. The objective is to copy all items.

            3. As expected - clicking / selecting an item in "list" adds it to "plaintextEdit_2"

            4. Only "list" and "plaintextEdit" gives option to "appendPlainText" hence "copy" QString to QString .
              Makes sense, but I like to see copy all "items" not a single string .

            My guess is the text widgets contents ( string or item ) should match - but the widget titles are misleading.

            Sorry for being persistent - back to experimenting.

            8d68406c-f17c-425b-bd11-c44f5d4cbf79-image.png

            Pl45m4P Offline
            Pl45m4P Offline
            Pl45m4
            wrote on last edited by Pl45m4
            #5

            @AnneRanch said in Edit QtDesigner "connect" - is it possible ?:

            the "connect" - third line in attached screen shot - fills/ copy ONLY one item. The objective is to copy all items.

            Because the given slots and signals have no logic involved. If you want to have some custom behavior, you need to "tell" your program what to do. The default slots can only provide default or very basic stuff.
            The first user wants to copy 1 item, the second wants to copy all, the third wants to copy only 5... Qt cant provide default slots for every single possibilty...

            Only "list" and "plaintextEdit" gives option to "appendPlainText" hence "copy" QString to QString .
            Makes sense, but I like to see copy all "items" not a single string .

            See answer above. This is no standard behavior. The QtD default connection is also only possible, if the signal and slot parameters match. You cant connect a signal that passes an item to a slot, that expects a QString, without adding further logic.

            You need to take your items, get their (item->text()) and then send the QString returned to your plainTextEdit. Then YOU can decide, whether you want to add one, three, 500 or 7 million...

            Your slot could look like this

            void MainWindow::sendItemsToTextEdit()
            {
                 for ( int i = 0; i  < ui->list.size(); i++)
                  {
                        ui->plainTextEdit->appendPlainText(ui->list.at(i)->text());
                  }
            }
            

            If debugging is the process of removing software bugs, then programming must be the process of putting them in.

            ~E. W. Dijkstra

            A 1 Reply Last reply
            1
            • Pl45m4P Pl45m4

              @AnneRanch said in Edit QtDesigner "connect" - is it possible ?:

              the "connect" - third line in attached screen shot - fills/ copy ONLY one item. The objective is to copy all items.

              Because the given slots and signals have no logic involved. If you want to have some custom behavior, you need to "tell" your program what to do. The default slots can only provide default or very basic stuff.
              The first user wants to copy 1 item, the second wants to copy all, the third wants to copy only 5... Qt cant provide default slots for every single possibilty...

              Only "list" and "plaintextEdit" gives option to "appendPlainText" hence "copy" QString to QString .
              Makes sense, but I like to see copy all "items" not a single string .

              See answer above. This is no standard behavior. The QtD default connection is also only possible, if the signal and slot parameters match. You cant connect a signal that passes an item to a slot, that expects a QString, without adding further logic.

              You need to take your items, get their (item->text()) and then send the QString returned to your plainTextEdit. Then YOU can decide, whether you want to add one, three, 500 or 7 million...

              Your slot could look like this

              void MainWindow::sendItemsToTextEdit()
              {
                   for ( int i = 0; i  < ui->list.size(); i++)
                    {
                          ui->plainTextEdit->appendPlainText(ui->list.at(i)->text());
                    }
              }
              
              A Offline
              A Offline
              Anonymous_Banned275
              wrote on last edited by
              #6

              @Pl45m4 Ok, what you saying is the QtDesigner is limited to some action which is really not implemented as normal "connect" QtCreator signal/ slot . Even the terminology is little different - no more just object but sender and receiver . Both limited to "current " object.

              It is as "connect" but it is not editable as C code.
              You said to check .ui file, but
              QtDesigner .ui file opens only in GUI .

              How can I bypass that?

              I have no issue with "connecting" widgets with comparable methods - string to string , item to item.

              My current ask is to "connect" two dialogs and so far I have been using QtDesigner as a test bed. That is why I have been looking for a C code I could just modify - use different objects.

              I should be able to "convert " the invisible "connect" created by QtDesigner to connect two objects using real "connect".
              (QtDesigner is useful only on current object )

              Appreciate all your input, it is very helpful to be able to discuss the issue on the forum.

              Pl45m4P 1 Reply Last reply
              0
              • A Anonymous_Banned275

                @Pl45m4 Ok, what you saying is the QtDesigner is limited to some action which is really not implemented as normal "connect" QtCreator signal/ slot . Even the terminology is little different - no more just object but sender and receiver . Both limited to "current " object.

                It is as "connect" but it is not editable as C code.
                You said to check .ui file, but
                QtDesigner .ui file opens only in GUI .

                How can I bypass that?

                I have no issue with "connecting" widgets with comparable methods - string to string , item to item.

                My current ask is to "connect" two dialogs and so far I have been using QtDesigner as a test bed. That is why I have been looking for a C code I could just modify - use different objects.

                I should be able to "convert " the invisible "connect" created by QtDesigner to connect two objects using real "connect".
                (QtDesigner is useful only on current object )

                Appreciate all your input, it is very helpful to be able to discuss the issue on the forum.

                Pl45m4P Offline
                Pl45m4P Offline
                Pl45m4
                wrote on last edited by Pl45m4
                #7

                @AnneRanch said in Edit QtDesigner "connect" - is it possible ?:

                You said to check .ui file, but
                QtDesigner .ui file opens only in GUI .
                How can I bypass that?

                It's just for you to see what happens, when you do something in your QtDesigner GUI.
                Open ui file in design mode (like usual), then switch to "Edit-Mode" (2nd vertical tab from top at the very left menu bar or Ctrl + 2).
                (Ctrl + 3 to go back to design mode)
                You will see the XML version of what you did in QtDesigner. But this is not for editing! Edit your ui in your GUI only to ensure that nothing goes wrong.

                My current ask is to "connect" two dialogs

                What dialogs?

                That is why I have been looking for a C code I could just modify - use different objects.

                It's always the same procedure:

                You have basically four things, you need to think of:

                • What do I want to connect?
                  • sender object
                • What action should trigger the result?
                  • signal
                • Where should my connection go?
                  • receiver object
                • What should happen, when this happens?
                  • slot / function in receiver

                Then you already have all of the four parameters you need, to make the connection on your own.

                Remember: You can access everything you add to your ui file by using the ui->... pointer.
                So you can connect from or to your list using ui->list in your connect statement (or code in general).

                In your slot you can add your logic to create the behavior you want.


                If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                ~E. W. Dijkstra

                1 Reply Last reply
                2
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Hi,

                  You should take a look at the Calculator Form example.

                  From a learning point of view, I would recommend to start by reading the documentation associated with Qt Designer, dig in the examples and then start doing more involved stuff.

                  You should also take the time to read about Signals and Slots to have a better grasp of what each is and what you can and cannot do with them.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  2

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved