Ok, it works properly. And how can I connect other dialog to one of actions defined in ui_maker.h?? Because I can't understand multiple inheritance
Printable View
Ok, it works properly. And how can I connect other dialog to one of actions defined in ui_maker.h?? Because I can't understand multiple inheritance
For example you can use the automatic connections mechanism, by adding a specially named slot to your class:Where someAction is the name of the action you want to connect to and triggered() is the signal you want to react on.Code:
void MainWindow::on_someAction_triggered() { OtherDialog dlg( this ); dlg.exec(); }
It looks like you have taken the single inheritance approach, so you don't use the multiple inheritance anywhere.
Ok, so I create slot:
And, what's the next step?Code:
void MainWindow::on_actionAbout_triggered() { OtherDialog dlg( this ); dlg.exec(); }
Can't you just follow a tutorial or something? It'll be way faster if you do...
What does multiple inheritance have to do with the code you pasted above?
Here is a list of different examples and tutorials which you might want to take a look at:
http://doc.trolltech.com/4.2/examples.html
Here is an article stating step by step how to use forms created in Designer:
http://doc.trolltech.com/4.2/designe...component.html
Here is a link to The Independent Qt Tutorial by Johan Thelin which is a tutorial on Qt3 for beginners. If you have trouble handling Qt basics, it'll be fine for you even if you use Qt4:
http://www.digitalfanatics.org/projects/qt_tutorial/
The problem is that you're asking questions without telling us what you want. In particular I have no idea what "next step" you were referring to in your previous post. We don't know what you already did, what you're planning to do, etc.
I don't understand. The only thing that I have to do is defining this? But what should be in OtherDialog and dlg places in my case, if I have a Main Window called MainWindow and all actions defined in ui_maker.h file? This file is designed by designer. And I have to include this ui_Dialog file, yes? Regards
I don't understand. The only thing that I have to do is defining this? But what should be in OtherDialog and dlg places in my case, if I have a Main Window called MainWindow and a dialog called Dialog? All actions aredefined in ui_maker.h file, this file is designed by designer. I have this two files: maker.h:
and ui_about:Code:
#ifndef MAKER_H #define MAKER_H #include "ui_maker.h" { Q_OBJECT public: private slots: void abcziom(); void cbaziom(); private: Ui::MainWindow ui; }; #endif
Code:
#ifndef UI_ABOUT_H #define UI_ABOUT_H #include <QtCore/QVariant> #include <QtGui/QAction> #include <QtGui/QApplication> #include <QtGui/QButtonGroup> #include <QtGui/QDialog> #include <QtGui/QLabel> #include <QtGui/QPushButton> class Ui_Dialog { public: QLabel *label; QLabel *label_2; QLabel *label_3; QPushButton *pushButton; { label->setLayoutDirection(Qt::LeftToRight); label->setTextFormat(Qt::AutoText); label_2->setLineWidth(1); label_2->setMidLineWidth(0); label_2->setTextFormat(Qt::RichText); label_2->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop); label_2->setWordWrap(true); pushButton->setDefault(true); pushButton->setFlat(false); retranslateUi(Dialog); size = size.expandedTo(Dialog->minimumSizeHint()); Dialog->resize(size); } // setupUi { Dialog->setAccessibleName(QApplication::translate("Dialog", "About", 0, QApplication::UnicodeUTF8)); label->setText(QApplication::translate("Dialog", "About TimeTable Maker", 0, QApplication::UnicodeUTF8)); label_3->setText(QApplication::translate("Dialog", "Thank you for using TimeTable Maker", 0, QApplication::UnicodeUTF8)); Q_UNUSED(Dialog); } // retranslateUi }; namespace Ui { class Dialog: public Ui_Dialog {}; } // namespace Ui #endif // UI_ABOUT_H
I think you mentioned you have the book "GUI Programming with Qt4". Did you read the second chapter? Especially sections "Subclassing QDialog" and "Rapid Dialog Design"? These explain how to do what you're trying to do.
No, but I'll read it ;) Ok, so I will look at it
Don't have a look. Read it.
And after it I will know how to do it...I would like to know ;)
Yes. You're asking about very simple things and it seems that you even didn't look at the documentation or the book. We won't teach you C++ here. If you have trouble with C++ I suggest you also take a look at our links section and download (and read, at least parts of it) "Thinking in C++".
I'd like the Chapter 2 to be simplier than designer using a component? ;) But there isn't much to do with the code in post #50, right?
Read and understand the chapter. We can give you the exact code for your problem but then you won't learn anything and you'll come right back with a simmilar issue.
But in book, there appear one more line after QApplication app... It's
which not appear in my application, but it works.Code:
Ui::MainWindow ui
Hi than. I read chapter 2, I understand it, but I still don't know how to connect action to another dialog. It shows how to make slots and use it, but not how to connect two different dialogs. Regards