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. Running multiple Instances of a dialogue box with widgets
Forum Updated to NodeBB v4.3 + New Features

Running multiple Instances of a dialogue box with widgets

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 449 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.
  • L Offline
    L Offline
    leinad
    wrote on 21 Jul 2020, 18:30 last edited by
    #1

    Hi,

    I created a QDialogue window. In that window, I used QtCreator to place a couple of combo-boxes and check boxes.

    When I create an multiple instance of the same dialogue window, it appears to me that the QCombo-boxes are not unique to each QDialogie window. The widgets should be in scope just for that instance. I can tell they are the same comb-box instance because when I run qDebug() << ui->widget, every instance shows the same hex ID.

    Do I have to actually create the widgets on the fly using "new" for each instance of the dialogue window and place them in the same position or is there a trick where I can force ui->widget be a different instance for each instance of QDialogue? I could overlap widgets and show/hide what I don't need but that is a terrible design and of course I'm limited to the number instances I can run.

    Thanks.

    J 1 Reply Last reply 21 Jul 2020, 18:53
    0
    • L leinad
      21 Jul 2020, 18:30

      Hi,

      I created a QDialogue window. In that window, I used QtCreator to place a couple of combo-boxes and check boxes.

      When I create an multiple instance of the same dialogue window, it appears to me that the QCombo-boxes are not unique to each QDialogie window. The widgets should be in scope just for that instance. I can tell they are the same comb-box instance because when I run qDebug() << ui->widget, every instance shows the same hex ID.

      Do I have to actually create the widgets on the fly using "new" for each instance of the dialogue window and place them in the same position or is there a trick where I can force ui->widget be a different instance for each instance of QDialogue? I could overlap widgets and show/hide what I don't need but that is a terrible design and of course I'm limited to the number instances I can run.

      Thanks.

      J Offline
      J Offline
      JonB
      wrote on 21 Jul 2020, 18:53 last edited by JonB
      #2

      @leinad
      If you put widgets on widget in Creator, that's fine, you get quite separate instances of those sub-widgets every time you create an instance of the top-level widget (dialog in your case). If you are finding otherwise, something is wrong (in your usage).

      1 Reply Last reply
      1
      • L Offline
        L Offline
        leinad
        wrote on 22 Jul 2020, 12:59 last edited by
        #3

        Hmm, I wonder what I can be doing wrong? I simply print out the widget ID and it is always the same. I decided to just create new widgets and place them on the layout.

        M 1 Reply Last reply 22 Jul 2020, 13:30
        0
        • L leinad
          22 Jul 2020, 12:59

          Hmm, I wonder what I can be doing wrong? I simply print out the widget ID and it is always the same. I decided to just create new widgets and place them on the layout.

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 22 Jul 2020, 13:30 last edited by mrjj
          #4

          @leinad
          Its very had to guess at when you show no code.

          qDebug() << ui->widget shows the address of the widget so its not an id as such.
          and dont means much as the memory might get reused etc.

          Also if you create different instances of the QDialogue then its impossible they are the same.

          also

          • it appears to me that the QCombo-boxes are not unique to each QDialogie window.

          That is not really possible as a Widget can only be in one container at the same time so
          its not the same one, but just an instance.

          1 Reply Last reply
          0
          • L Offline
            L Offline
            leinad
            wrote on 22 Jul 2020, 15:47 last edited by
            #5

            Thank you. I see what my problem was, When I started multiple instances, I do an emit to send the data to process. Turns out the emit sends to every instance (daaahhh), so of course I'll see duplicated information across instances. So now I send an ID number so each instance knows by ID number whether the information belongs to it or some other instance.

            Thanks.

            1 Reply Last reply
            1

            1/5

            21 Jul 2020, 18:30

            • Login

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