Solved how to duplicate widget
-
@wabisuke2718 A widget is just a C++ class so you create an instance as any other:
MyWidget *widget = new MyWidget(parent);
-
@wabisuke2718
You can always take a look in the .ui file which QDesigner will generate. You can see how it builds the widgets in code and adapt the code in your own coded widget if you want to. -
- So is there no way to duplicate complex QFrames like the next image created in design mode at run time?
Hi, what ever u draw in Designer also exists as code.
If you go to the form and look int SetupUI() function, you will see
all the code that creates such a Frame.You can then easy make it a function and just call that to create more of them.
Copy code to other file as the ui_xx file is generated. -
Hi,
Is this widget meant to show each entry listed in your mastodon feed ?
-
@SGaist yes
-
In that case, it will likely make more sense to use a QListView with a custom QStyledItemDelegate and a custom model to hold your data. Otherwise you'll end up with thousands of widgets which is not the best performance-wise for showing a list with basically static content.
-
@mrjj That is a good idea.Please tell me how we can change duplicate ui_x.h and ui_y.h files at run time for two UI of same class?
-
Why you need to do that?
Just create multiple instances of the same class?! -
-
@Ayush92
For anyone reading this/tempted to answer, please note that the OP is asking the same question in https://forum.qt.io/topic/119689/gui-from-xml-in-c [where I have tried to answer]. We don't want to keep answering the same issues in multiple threads....