Results 1 to 11 of 11

Thread: qt4.1.1 designer

  1. #1
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default qt4.1.1 designer

    OS: WINXP
    Compiler: MINGW 4.1.1
    QT: QT 4.1.1

    Hello everybody,
    Its really time to make a important step in my live...jump from qt3 to 4

    I have read some docs and tried tutorials..
    I have a question about using designer in the right steps:

    1. I have created a widget, connection in the designer and save it "test1.ui"
    2. I have created by hand a "test1.pro":
    Qt Code:
    1. TEMPLATE = app
    2. FORMS = test1.ui
    3. SOURCES = main.cpp
    To copy to clipboard, switch view to plain text mode 

    3. I have created a main.cpp:
    Qt Code:
    1. #include "ui_test1.h"
    2. #include <QApplication>
    3.  
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication app(argc, argv);
    8. QDialog *window = new QDialog;
    9. Ui::Dialog ui;
    10. ui.setupUi(window);
    11.  
    12. window->show();
    13. return app.exec();
    14. }
    To copy to clipboard, switch view to plain text mode 

    4. compile and get exe file

    My Question: how to get a cpp file to implement my functions?And are my steps correct?Have i to create by hand the cpp? Its right that if i include "ui_test.h" in main.cpp the file will created?Have i to create the main.cpp by hand?

    I want to use the designer to design my app
    Think DigitalGasoline

  2. #2
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: qt4.1.1 designer

    Looks like you followed this document:

    http://doc.trolltech.com/4.1/designe...component.html

    Scroll down to http://doc.trolltech.com/4.1/designe...tance-approach

    or further to see examples where you can hook in your code.
    It's nice to be important but it's more important to be nice.

  3. #3
    Join Date
    Jan 2006
    Location
    Lincoln, NE USA
    Posts
    177
    Thanks
    3
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qt4.1.1 designer

    Quote Originally Posted by raphaelf
    OS: WINXP
    Compiler: MINGW 4.1.1
    QT: QT 4.1.1

    Hello everybody,
    Its really time to make a important step in my live...jump from qt3 to 4
    ...snip...
    My Question: how to get a cpp file to implement my functions?And are my steps correct?Have i to create by hand the cpp? Its right that if i include "ui_test.h" in main.cpp the file will created?Have i to create the main.cpp by hand?

    I want to use the designer to design my app
    I jumped from QT3 to QT4 too, and below is a link to an HTML file that explains how I made my first app under Qt4. Also, I use the designer for the gui's.

    http://www.qtcentre.org/forum/attach...5&d=1138742423

  4. #4
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qt4.1.1 designer

    But that link is not accessible to anyone but you
    We can't solve problems by using the same kind of thinking we used when we created them

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qt4.1.1 designer

    Quote Originally Posted by sunil.thaha
    But that link is not accessible to anyone but you
    Is it? I can read it fine.

  6. #6
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Cool Re: qt4.1.1 designer

    hi everybody, thx for all replies..

    I hope i am in the right way

    Please let me now if i am in the right way or not, AND WHY I CANT SEE A Messagebox after clicking my okButton ;(

    my steps:
    1. Design my MainWindow
    2. i have created a main.cpp:
    Qt Code:
    1. #include "ui_mainwindow.h"
    2. #include <QApplication>
    3.  
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication app(argc, argv);
    8. QDialog *window = new QDialog;
    9. Ui::MainWindow ui;
    10. ui.setupUi(window);
    11.  
    12. window->show();
    13. return app.exec();
    14. }
    To copy to clipboard, switch view to plain text mode 
    3. I have created a test.h:
    Qt Code:
    1. #include "ui_mainwindow.h"
    2.  
    3.  
    4.  
    5. class MainWindow : public QDialog
    6. {
    7. Q_OBJECT
    8.  
    9. public:
    10. MainWindow(QWidget *parent = 0);
    11.  
    12. public slots:
    13. void myfirstfunction();
    14.  
    15.  
    16. private:
    17. Ui::MainWindow ui;
    18.  
    19.  
    20.  
    21. };
    To copy to clipboard, switch view to plain text mode 
    4. I have created a test.cpp:
    Qt Code:
    1. #include "test.h"
    2.  
    3. #include <QMessageBox>
    4.  
    5. MainWindow::MainWindow(QWidget *parent)
    6. : QDialog(parent)
    7. {
    8. ui.setupUi(this);
    9.  
    10.  
    11.  
    12. connect(ui.okButton, SIGNAL(clicked()), this, SLOT(myfirstfunction()));
    13. connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
    14. }
    15.  
    16. void MainWindow::myfirstfunction()
    17. {
    18. QMessageBox::information(this, "Application name",
    19. "Unable to find the user preferences file.\n"
    20. "The factory default will be used instead.");
    21.  
    22. }
    To copy to clipboard, switch view to plain text mode 
    5. qmake -project

    .pro file:
    Qt Code:
    1. ######################################################################
    2. # Automatically generated by qmake (2.00a) Sa 25. Feb 22:31:12 2006
    3. ######################################################################
    4.  
    5. TEMPLATE = app
    6. TARGET +=
    7. DEPENDPATH += .
    8. INCLUDEPATH += .
    9.  
    10. # Input
    11. HEADERS += test.h
    12. FORMS += mainwindow.ui
    13. SOURCES += main.cpp test.cpp
    To copy to clipboard, switch view to plain text mode 

    6. qmake
    7. make I get a exe file without error

    By clicking my okButton i cant see my Messagebox by calling myfirstfunction().
    Last edited by raphaelf; 25th February 2006 at 22:57.
    Think DigitalGasoline

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qt4.1.1 designer

    Looks like you have two Ui::MainWindow objects -- one in main (which is used to show widgets) and the other as a private member of MainWindow (which is connected to a slot), meaning, that you have connected the wrong button to the slot. Remove the object from main().

  8. #8
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: qt4.1.1 designer

    hi wysota, like that it works:
    Qt Code:
    1. #include "test.h"
    2. #include <QApplication>
    3.  
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication app(argc, argv);
    8. MainWindow m;
    9. m.show();
    10. return app.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 

    Wysota, i am using the correct way?
    If i would like to not Subclass "ui_mainwindow.h" and use itself, have i to define my functions there and create a new mainwindow.cpp and implement it there?Will "ui_mainwindow.h" not overwritten?

    For example if i have 10 Dialogs...Have i everytime to subclass every ui_XXX.h ??
    Last edited by raphaelf; 26th February 2006 at 12:36.
    Think DigitalGasoline

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qt4.1.1 designer

    You should. In theory you probably could try passing a pointer or a reference to your UI structure, but I don't recommend that. Basicly you should either subclass every ui you create or implement a dynamic dialog, which will change according to your needs (for example including dynamic form (UI) loading). If you don't want to subclass every dialog manualy, you can create a script which will do it for you, you'll just need to fill in the details.

  10. #10
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: qt4.1.1 designer

    hi..
    ok so i should subclass it every dialog, mainwindow...
    So my example was correct?
    Think DigitalGasoline

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qt4.1.1 designer

    The one in your previous post? Yes.

Similar Threads

  1. Threads in Designer plugins
    By hvengel in forum Qt Tools
    Replies: 2
    Last Post: 3rd January 2009, 20:19
  2. Replies: 13
    Last Post: 15th December 2006, 12:52
  3. Designer crashes when selecting some widgets
    By gwendal in forum Qt Tools
    Replies: 4
    Last Post: 21st July 2006, 14:18
  4. Arthur Plugins demos and designer
    By antonio.r.tome in forum Installation and Deployment
    Replies: 4
    Last Post: 21st March 2006, 15:01
  5. define column in designer QT4.1.1
    By raphaelf in forum Qt Tools
    Replies: 2
    Last Post: 26th February 2006, 21:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.