Please, consider going through the nice tutorials shipped with Qt, starting from Qt Tutorial 1 - Hello World. We are not here to teach you the basics but to help you with problems you may encounter.![]()
Please, consider going through the nice tutorials shipped with Qt, starting from Qt Tutorial 1 - Hello World. We are not here to teach you the basics but to help you with problems you may encounter.![]()
J-P Nurmi
I have C++ GUI Programming with Qt 4 book. And I know something already, but I can't do anything about that, so I will ask you once more, to correct my code![]()
I added this:
into Ui_MainWindow class. Is that correctly?Qt Code:
void Ui_MainWindow::openUi_Dialog(){ static Ui_Dialog *Ui_Dialog = new Ui_Dialog(this); Ui_Dialog->show(); Ui_Dialog->activateWindow(); // or form2->setActiveWindow() in Qt3 Ui_Dialog->raise(); }To copy to clipboard, switch view to plain text mode
EDIT:
No, it isn't. When I do it I have errors that MainWindow class does not have a member called raise, acitvateWindow and show. Even if I paste it out of this class there are errors:
class Ui-Dialog has no member called raise, show and activateWindow. So how should I do it?
Last edited by Salazaar; 13th May 2007 at 20:02.
Again with big red characters:
Don't change the code of the class generated by UIC. Subclass along the proper widget class and put additional code there.
There... I hope that makes it clearOh... and I'm sure it's well explained in the book you mentioned.
Ok, I won't change the code, so how can I connect dialog to actionAbout slot? I'd be satisfied with a code.![]()
Regards
-------------------
Widzę, że nie jestem sam na tym forum![]()
You don't have a dialog. You only have an UI definition. You have to use the definition on a dialog and not on its own. You're asking for code and we're constantly redirecting you to an article that contains the code you ask for. Furthermore GUI Programming with Qt4 book also contains the code you ask for. Please read and follow "The Single Inheritance Approach" section from the docs.
Right. Than, I have a question concerning code that jpn gave me:Why it's ? I didn't find anything what should be called by this.Qt Code:
#include "ui_Maker.h" int main(int argc, char *argv[]) { Ui::MainWindow ui; ui.setupUi(window); window->show(); return app.exec(); }To copy to clipboard, switch view to plain text mode
Like The Single Inheritance Approach and The Multiple Inheritance Approach ... Ok, I'm working at it... and this MainWindow is the name of my main window which I gave to it by designer, right?
But Direct Approach shows how to show the dialog, not to make changes in it. And to not to make a new thread, I'll ask here, can I create slots in designer? And in this code, which is here: http://doc.trolltech.com/4.2/designe...tance-approach
I have to paste into main.cpp file, right?
Edit:
Patrik, there's no problem with creating main file, but with connecting mainwindow to other applications and with creating slots
Last edited by Salazaar; 14th May 2007 at 09:01.
No, you can't create slots in Designer.
Look at the Calculator Form Example. It uses the single inheritance approach and custom slots.And in this code, which is here: http://doc.trolltech.com/4.2/designe...tance-approach
I have to paste into main.cpp file, right?
J-P Nurmi
But in http://doc.trolltech.com/4.2/designe...tance-approach it shows how to add a custom slot, but it doesn't show how to connect action to another dialog
Last edited by Salazaar; 14th May 2007 at 19:01.
Please connect all the knowledge gathered in this thread and use it together. If you have any doubt, consult the FAQ and the article you were given. If you still have problems, ask *specific* questions.
Hi. So, I've got a question. There appear errors:
In member function void MainWindow::cbazion()
expected primary-expression before ) token
expected ; before) token
expected } at end of input
And this is this file:
Qt Code:
#include <QtGui> #include "maker.h" { ui.setupUi(this); } void MainWindow::abcziom() { } void MainWindow::cbaziom() { )To copy to clipboard, switch view to plain text mode
Could you post the contents of maker.h file?
You have a right bracket instead of a right brace in the last line.
This is the full maker.h content:
So, what's wrong?Qt Code:
#ifndef MAKER_H #define MAKER_H #include "ui_maker.h" { Q_OBJECT public: private slots: void abcziom(); void cbaziom(); private: Ui::MainWindow ui; }; #endifTo copy to clipboard, switch view to plain text mode
I use a tool to create cpp (source) && h (header file)
Finaly on main to show the gui you use on main...
## MainWindow is class name....
MainWindow::self()->setWindowTitle( _PROGRAM_TITLE_ );
MainWindow::self()->show();
download QTutils tool -> http://ppk.ciz.ch/qt_c++/QT_utils.zip
cd QT_utils
qmake
make
Open QTUtils insert the class name on top && select mainwindow/Dialog/Widged type same as ui file && generate the code as header & source ... or only as header....
Put the file on projekt dir && run && main.cpp
on cmd dir qmake -project
call the dialog on main...
but on top from pro file ...
MOC_DIR = build/.moc
RCC_DIR = build/.rcc
OBJECTS_DIR = build/.obj
UI_DIR = ui
and final
qmake && make.
Bookmarks