namespace Ui {class TableDialog;}class TableDialog : public QDialog{ Q_OBJECTpublic: explicit TableDialog(QWidget *parent = 0); ~TableDialog();private: Ui::TableDialog *ui;private slots: void addItemTableDialog(const QString &str);};
<?xml version="1.0" encoding="UTF-8"?><ui version="4.0"> <class>TableDialog</class> <widget class="QDialog" name="TableDialog"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>485</width> <height>85</height> </rect> </property> <property name="windowTitle"> <string>Dialog</string> </property> <layout class="QGridLayout" name="gridLayout"> <item row="0" column="0"> <layout class="QVBoxLayout" name="verticalLayout"> <item> <widget class="QComboBox" name="comboBox"> <property name="minimumSize"> <size> <width>50</width> <height>25</height> </size> </property> <property name="maximumSize"> <size> <width>16777215</width> <height>25</height> </size> </property> <property name="insertPolicy"> <enum>QComboBox::InsertAtCurrent</enum> </property> </widget> </item> <item> <widget class="QDialogButtonBox" name="buttonBox"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> <property name="standardButtons"> <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> </property> </widget> </item> </layout> </item> </layout> </widget> <resources/> <connections> <connection> <sender>buttonBox</sender> <signal>accepted()</signal> <receiver>TableDialog</receiver> <slot>accept()</slot> <hints> <hint type="sourcelabel"> <x>248</x> <y>254</y> </hint> <hint type="destinationlabel"> <x>157</x> <y>274</y> </hint> </hints> </connection> <connection> <sender>buttonBox</sender> <signal>rejected()</signal> <receiver>TableDialog</receiver> <slot>reject()</slot> <hints> <hint type="sourcelabel"> <x>316</x> <y>260</y> </hint> <hint type="destinationlabel"> <x>286</x> <y>274</y> </hint> </hints> </connection> </connections></ui>
void TableDialog::addItemTableDialog(QString str){ ui->comboBox->addItem(str); QFile file("C:/log.txt"); QTextStream out(&file); if (file.open(QIODevice::WriteOnly)) { //file.write(str); out<<"OK: " <<str; } file.close();}