greetings,
i am using a component usign multiple inhritance approach. I has got a tabWidget, a push button and a table widget. On press of a push button i want this table widget to appear and go.
here is how my code look like.
ui file for dialog
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>TitleForm2</class>
<widget class="QWidget" name="TitleForm2" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>401</width>
<height>302</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<widget class="QTabWidget" name="tabWidget" >
<property name="geometry" >
<rect>
<x>40</x>
<y>40</y>
<width>301</width>
<height>80</height>
</rect>
</property>
<widget class="QWidget" name="tab" >
<attribute name="title" >
<string>Tab 1</string>
</attribute>
</widget>
<widget class="QWidget" name="tab_2" >
<attribute name="title" >
<string>Tab 2</string>
</attribute>
</widget>
</widget>
<widget class="QPushButton" name="pbnOk" >
<property name="geometry" >
<rect>
<x>250</x>
<y>130</y>
<width>87</width>
<height>29</height>
</rect>
</property>
<property name="text" >
<string>More</string>
</property>
</widget>
<widget class="QWidget" name="" >
<property name="geometry" >
<rect>
<x>60</x>
<y>180</y>
<width>258</width>
<height>101</height>
</rect>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="Line" name="line" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tableWidget" />
</item>
</layout>
</widget>
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections>
<connection>
<sender>pbnOk</sender>
<signal>toggled(bool)</signal>
<receiver>TitleForm2</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>275</x>
<y>158</y>
</hint>
<hint type="destinationlabel" >
<x>270</x>
<y>178</y>
</hint>
</hints>
</connection>
</connections>
</ui>
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>TitleForm2</class>
<widget class="QWidget" name="TitleForm2" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>401</width>
<height>302</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<widget class="QTabWidget" name="tabWidget" >
<property name="geometry" >
<rect>
<x>40</x>
<y>40</y>
<width>301</width>
<height>80</height>
</rect>
</property>
<widget class="QWidget" name="tab" >
<attribute name="title" >
<string>Tab 1</string>
</attribute>
</widget>
<widget class="QWidget" name="tab_2" >
<attribute name="title" >
<string>Tab 2</string>
</attribute>
</widget>
</widget>
<widget class="QPushButton" name="pbnOk" >
<property name="geometry" >
<rect>
<x>250</x>
<y>130</y>
<width>87</width>
<height>29</height>
</rect>
</property>
<property name="text" >
<string>More</string>
</property>
</widget>
<widget class="QWidget" name="" >
<property name="geometry" >
<rect>
<x>60</x>
<y>180</y>
<width>258</width>
<height>101</height>
</rect>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="Line" name="line" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tableWidget" />
</item>
</layout>
</widget>
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections>
<connection>
<sender>pbnOk</sender>
<signal>toggled(bool)</signal>
<receiver>TitleForm2</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>275</x>
<y>158</y>
</hint>
<hint type="destinationlabel" >
<x>270</x>
<y>178</y>
</hint>
</hints>
</connection>
</connections>
</ui>
To copy to clipboard, switch view to plain text mode
.h file
#include"ui_titleForm2.h"
#include<QDialog>
class TF2
: public QDialog,
public Ui
::TitleForm2{Q_OBJECT
public:
public slots:
void hide(bool);
};
#include"ui_titleForm2.h"
#include<QDialog>
class TF2 : public QDialog, public Ui::TitleForm2
{Q_OBJECT
public:
TF2(QWidget *parent=0);
public slots:
void hide(bool);
};
To copy to clipboard, switch view to plain text mode
and .cpp file
#include "titleForm2.h"
#include<QTableWidget>
#include<iostream>
{ setupUi(this);
tableWidget->setVisible(false);
connect(pbnOk,SIGNAL(toggled(bool)),tableWidget,SLOT(setVisible(bool)));
connect(pbnOk,SIGNAL(toggled(bool)),this,SLOT(hide(bool)));
}
void TF2::hide(bool b)
{ //control not reaching here
tableWidget->setVisible(b);
std::cout<<" "<<b<<" |";
}
#include "titleForm2.h"
#include<QTableWidget>
#include<iostream>
TF2::TF2(QWidget *parent):QDialog(parent),TitleForm2()
{ setupUi(this);
tableWidget->setVisible(false);
connect(pbnOk,SIGNAL(toggled(bool)),tableWidget,SLOT(setVisible(bool)));
connect(pbnOk,SIGNAL(toggled(bool)),this,SLOT(hide(bool)));
}
void TF2::hide(bool b)
{ //control not reaching here
tableWidget->setVisible(b);
std::cout<<" "<<b<<" |";
}
To copy to clipboard, switch view to plain text mode
i has debugged that my code is not reaching to respective commented line. I has connected this signal in designer also.
and main is
#include<QApplication>
#include"titleForm2.h"
int main(int argc, char**argv)
{
TF2 t;
t.show();
return a.exec();
}
#include<QApplication>
#include"titleForm2.h"
int main(int argc, char**argv)
{
QApplication a(argc,argv);
TF2 t;
t.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
In this i couldn't figure outt why this signal is not getting connected.
quickNitin
Bookmarks