How to access objects of parent Dialog from Child Dialog .
-
hello friends,I have a doubt,Now when i click on any date in calendar widget,I have written slot so as to show the date in a textbrowser as shown in code below
@void Dialog::on_Date_Clicked(QDate date)
{
ui->TextBrowser->setText(date.toString());}@
Now again when i click on selected date I want to open a newdialog
so on first click it shows the date in browser and on secondclick it should open a dialog..
so how should i proceed..regards
imrrk -
[quote author="imrrk" date="1302784064"]hello friends,I have a doubt,Now when i click on any date in calendar widget,I have written slot so as to show the date in a textbrowser as shown in code below
@void Dialog::on_Date_Clicked(QDate date)
{
ui->TextBrowser->setText(date.toString());}@
Now again when i click on selected date I want to open a newdialog
so on first click it shows the date in browser and on secondclick it should open a dialog..
so how should i proceed..regards
imrrk[/quote]Well, one way might be to compare the current content of the text browser with the string representation of the date that was clicked. If they match, then you open the dialog, if they don't, you only set the textual representation of the date in the text browser. Or one of the many, many other ways (most of them better structured than this one) you can do this.
imrrk, this is reall, really basic programming. I would recommend you do some kind of basic programming course, or at least get yourself a good book on the topic at beginners level.
-
[quote author="imrrk" date="1302951509"]hey i know andre,and i can do it,but in I am not understanding it in qt framework,so I asked it..
[/quote]The reason why I recommend you get yourself some basic knowledge, is that this question has nothing to do with Qt itself. You will run into the exact same issue in any framework and in any language. That's why I think you lack some basic knowledge to be an effective programmer.
-
ok andre,thanks for your advice,hey i i have tried something,just check out my code,
@#include "dialog.h"
#include "ui_dialog.h"
#include<QCalendarWidget>
#include<QDate>
#include "dialog1.h"
#include "ui_dialog1.h"
#include<QPainter>
#include <QtGui/QApplication>Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);connect(ui->calendarWidget,SIGNAL(clicked(QDate)),this,SLOT(showdate(QDate)));
}
Dialog::~Dialog()
{
delete ui;
}void Dialog::showdate(QDate date)
{
ui->lineEdit->setText(date.toString());}
void Dialog::showset(QDate date)
{if(ui->lineEdit->text()==date.toString())
{
Dialog1 a(this);
connect(&a,SIGNAL(setclicked()),this,SLOT(setcolors()));
connect(&a,SIGNAL(unsetclicked()),this,SLOT(unsetcolors()));
a.show();
a.exec();}
else
{
ui->lineEdit->setText("hello");
}}@
regards
imrrk -
imrrk, if you show us a piece of code, without telling us what to look for, do you really expect a reply? My guess is: it doesn't work as you expect, right?
Just a hint: you implemented a showset(QDate date) method, but you are not calling it anywhere. I think you should merge the showdate and showset methods into a single method.
-
[quote author="imrrk" date="1303117850"]hello andre,u already know what i want,so i showed my code,to show you what i have tried,and you r right ,i forgot to include that line,where i called showset method..[/quote]
Yes, it is clear what you want, but not what might be wrong with the code you show us. That is what I was asking about. I guess it doesn't do what you want, but that's not what you tell us.
On the show() and exec() calls. Just remove the show() call please, it is nonsense.
-
i have introduced the call in constructor but also it wont work and do you mean merging in this way
@void Dialog::showdate(QDate date)
{
ui->lineEdit->setText(date.toString());
connect(ui->calendarWidget,SIGNAL(activated(QDate)),this,SLOT(showset(QDate)));}
void Dialog::showset(QDate date)
{
Dialog1 a(this);connect(&a,SIGNAL(setclicked()),this,SLOT(setcolors()));
connect(&a,SIGNAL(unsetclicked()),this,SLOT(unsetcolors()));
a.showNormal();
a.exec();
}@