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. How to refer a dynamically added table widget inside a scroll area widget?
Forum Updated to NodeBB v4.3 + New Features

How to refer a dynamically added table widget inside a scroll area widget?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.0k 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.
  • A Offline
    A Offline
    aurora
    wrote on last edited by
    #1

    I have created a scroll area , inside that scroll area added a QToolBox...
    And in run time i'm adding pages to QToolBox....
    Each page contains a scroll area, inside that scroll area , number of QCheckBoxes are present....
    Now i want to get pointer to particular QCheckBox...by passing pagename and CheckBox name...

    Is that possible? If so please give some hint...
    my ui file
    @
    <?xml version="1.0" encoding="UTF-8"?>
    <ui version="4.0">
    <class>FilterColl</class>
    <widget class="QDialog" name="FilterColl">
    <property name="geometry">
    <rect>
    <x>0</x>
    <y>0</y>
    <width>686</width>
    <height>615</height>
    </rect>
    </property>
    <property name="sizePolicy">
    <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
    <horstretch>0</horstretch>
    <verstretch>0</verstretch>
    </sizepolicy>
    </property>
    <property name="windowTitle">
    <string>Dialog</string>
    </property>
    <layout class="QGridLayout" name="gridLayout">
    <item row="0" column="0" colspan="4">
    <widget class="QScrollArea" name="scrollArea">
    <property name="widgetResizable">
    <bool>true</bool>
    </property>
    <widget class="QWidget" name="scrollAreaWidgetContents">
    <property name="geometry">
    <rect>
    <x>0</x>
    <y>0</y>
    <width>666</width>
    <height>566</height>
    </rect>
    </property>
    <layout class="QGridLayout" name="gridLayout_2">
    <item row="0" column="0">
    <widget class="QToolBox" name="toolBox">
    <property name="sizePolicy">
    <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
    <horstretch>0</horstretch>
    <verstretch>0</verstretch>
    </sizepolicy>
    </property>
    <property name="currentIndex">
    <number>0</number>
    </property>
    <widget class="QWidget" name="page_2">
    <property name="geometry">
    <rect>
    <x>0</x>
    <y>0</y>
    <width>648</width>
    <height>521</height>
    </rect>
    </property>
    <attribute name="label">
    <string>STATUS</string>
    </attribute>
    </widget>
    </widget>
    </item>
    </layout>
    </widget>
    </widget>
    </item>
    <item row="1" column="3">
    <spacer name="horizontalSpacer">
    <property name="orientation">
    <enum>Qt::Horizontal</enum>
    </property>
    <property name="sizeHint" stdset="0">
    <size>
    <width>40</width>
    <height>20</height>
    </size>
    </property>
    </spacer>
    </item>
    <item row="1" column="1">
    <widget class="QPushButton" name="pushButton_OK">
    <property name="text">
    <string>OK</string>
    </property>
    </widget>
    </item>
    <item row="1" column="2">
    <widget class="QPushButton" name="pushButton_CANCEL">
    <property name="text">
    <string>CANCEL</string>
    </property>
    </widget>
    </item>
    <item row="1" column="0">
    <spacer name="horizontalSpacer_2">
    <property name="orientation">
    <enum>Qt::Horizontal</enum>
    </property>
    <property name="sizeHint" stdset="0">
    <size>
    <width>40</width>
    <height>20</height>
    </size>
    </property>
    </spacer>
    </item>
    </layout>
    </widget>
    <resources/>
    <connections/>
    </ui>

    @

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      I don't get the question. Are you looking for a QCheckBox, or for a table widget? Not that it matters much in how to go about it, but I think it makes clear that you don't know exactly what you want either.

      Are the check boxes on the form (make in designer), or did you create them in code dynamically?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        aurora
        wrote on last edited by
        #3

        Ya i want pointers to check boxes....which i added in code dynamically...

        The check boxes are inside QToolBox page....
        My function i expected as follows...
        @
        QCheckBox GetCheckBox(QString Checkboxname, QString ToolBoxPagename);
        @

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          The best way would be to just keep track of the check boxes you insert in some kind of data structure then. Perhaps something like this:

          @
          //in some header
          typedef QPair<QString, QString> CheckBoxKey;
          QHash<CheckBoxKey, QCheckBox*> m_checkBoxes;

          // retreive checkbox by name and page name. Returns 0 when checkbox is not found
          QCheckBox* getCheckBox(QString checkBoxName, QString toolBoxName)
          {
          CheckBoxKey key(checkBoxName, toolBoxName);
          return m_checkBoxes.value(key, 0);
          }

          //at the place where you create your checkboxes
          QCheckBox* cb = new QCheckBox(parent);
          CheckBoxKey key(checkBoxName, toolBoxName);
          m_checkBoxes.insert(key, cb);
          @

          1 Reply Last reply
          0
          • A Offline
            A Offline
            aurora
            wrote on last edited by
            #5

            Thanks a lot Andre...:)
            It works..!!!!

            1 Reply Last reply
            0

            • Login

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