Running multiple Instances of a dialogue box with widgets
-
wrote on 21 Jul 2020, 18:30 last edited by
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.
-
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.
wrote on 21 Jul 2020, 18:53 last edited by JonB@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). -
wrote on 22 Jul 2020, 12:59 last edited by
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.
-
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.
@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. -
wrote on 22 Jul 2020, 15:47 last edited by
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/5