Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I access a member tab of a QTabWidget class by using a variable name?
    primarykey
    data
    text
    <p>In a function I am currently working on, I am creating a multi-dimensional array of checkboxes, with the dimensions specified at run-time by the user. In order to represent the 'z' dimension, I create multiple tabs -- each one representing a different dimension -- and create an array of check boxes in each tab. The tabs are labeled dim1, dim2, dim3, ... etc.</p> <p>The problem I am having is the fact that in order to create the array of check boxes (within 3 'for' loops), I have to call the tabs as follows:</p> <pre><code>checkBoxVector.append(new QCheckBox( ui-&gt;dim1 )); </code></pre> <p>Where checkBoxVector holds pointers to the checkboxes. Now my first thought was that I would simply create a variable name that would change with each loop. With each iteration, it would go: "dim1", then "dim2", "dim3", ... etc. The problem with this is that I cannot reference the tabs with a string variable, I must type in the actual name of the tab. Here is a sample of that code:</p> <pre><code>int num = k+1; QString dim = "dim"; QString tab_name = dim.append(QString("%1").arg(num)); checkBoxVector.append(new QCheckBox( ui-&gt;tab_name )); </code></pre> <p>This gives me the error " 'class Ui::MainWindow' has no member named 'tab_name' ".</p> <p>Therefore; my question is: how can I apply this idea of changing the NAME of the tab with each loop, without causing such an error?</p> <p>EDIT: I think I forgot to mention that the tabs have already been created at this point, and have already been labeled with the "dim1", "dim2", "dim3", ... names. The only issue I am having is how to reference these tabs after they have been created. I feel like there is a simple syntax solution.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload