Results 1 to 16 of 16

Thread: Qt 3 program & Qt4 designer

  1. #1
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Qt 3 program & Qt4 designer

    I am running linux.
    I have a program writen with Qt 3.3 I want to re-write it using Qt-4.1 Designer. I would like my Qt 3 program ( in KDevelop 3 ) on one Desktop and the Qt4-Designer in another Desktop so I can toggle between them.
    How can I load Qt4 designer direcely from a terminal and not screw up my Qt 3?.

    Thanks for any help.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    85
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qt 3 program & Qt4 designer

    Call the designer with the whole path. On my system
    Qt 3:
    /usr/qt/3/bin/designer
    Qt 4:
    /usr/bin/designer

    When you only type designer it depends on the order of the paths in the PATH environment variable. You can view it with
    env | grep PATH

    The same applies to all other tools like qmake, moc and uic.

  3. #3
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qt 3 program & Qt4 designer

    Thanks Codepoet. I really am stupid. i thought I had looked in /usr/bin but I guess my 80 years is catching up with me.

  4. #4
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qt 3 program & Qt4 designer

    OK, I have my qt4 designer up. I have my layout the way I want it
    I don't see in qt4 where you load or develop the ".pro" file or the "main.cpp" file. that were available in Qt3.
    I didn't see them in the "Getting Started" in the Qt4 Designer manual example.
    What am I missing?

  5. #5
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    99
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Qt 3 program & Qt4 designer

    have a look at this video :
    http://www.trolltech.com/video/qt4/browser.html

    Basically in QT4 you use your editor of your choice to make the pro and main.cpp file. There isn't an editor in QT4 anymore.

    Cheers

  6. #6
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qt 3 program & Qt4 designer

    Quote Originally Posted by Everall
    have a look at this video :
    http://www.trolltech.com/video/qt4/browser.html

    Basically in QT4 you use your editor of your choice to make the pro and main.cpp file. There isn't an editor in QT4 anymore.

    Cheers
    Thanks for the info.

    pete

  7. #7
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qt 3 program & Qt4 designer

    i'm back.
    I have a label.ui, a label.h, a label.cpp and a main.cpp.
    #include <QApplication>
    #include "label.h"

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    Label label;
    label.show();
    return app.exec();
    }
    which gives me a simple window with a title. Now I want to incorporate my label.ui file. following the example in the "docs"
    #include <QApplication>

    #include "ui_labels.h" // defines the Ui::MyForm struct
    #include "label.h"

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    Label label;

    Ui::label ui;
    ui.setupUi(&label);

    label.show();
    return app.exec();
    }
    and when I run "qmake -project", "qmake labelform.pro" and "make" I get
    main.cpp:28:59: error: ui_labels.h: No such file or directory
    main.cpp: In function ‘int main(int, char**)’:
    main.cpp:36: error: ‘Ui’ has not been declared
    main.cpp:36: error: expected `;' before ‘ui’
    main.cpp:36: warning: statement has no effect
    main.cpp:37: error: ‘ui’ was not declared in this scope
    make: *** [main.o] Error 1
    I am at a loss on how to handle these instructions
    Like before, Qt Designer still writes out .ui files that contain the specification of an interface, and uic generates C++ code based on the .ui file. What has changed is that uic now generates a simple struct containing all the widgets and a setupUi() function that creates the widgets and layouts. The struct does not inherit from QObject and is entirely defined in a header file.
    I would really appreciate some help. thanks

    or is there an example that does this?
    Last edited by impeteperry; 20th March 2006 at 17:00.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt 3 program & Qt4 designer

    Quote Originally Posted by impeteperry
    #include "ui_labels.h"
    Shouldn't it be:
    Qt Code:
    1. #include "ui_label.h"
    To copy to clipboard, switch view to plain text mode 
    (remember to rerun qmake).

    Quote Originally Posted by impeteperry
    is there an example that does this?
    http://doc.trolltech.com/4.1/designe...tance-approach

  9. #9
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qt 3 program & Qt4 designer

    Thanks Jacek
    I made the correction, ran qmake -project, qmake labelform.pro and make and got
    main.cpp:37: error: ‘label’ is not a member of ‘Ui’
    main.cpp:37: error: expected `;' before ‘ui’
    main.cpp:38: error: ‘ui’ was not declared in this scope
    do I have to add anything to "label.h" ?
    Last edited by impeteperry; 20th March 2006 at 18:09.

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt 3 program & Qt4 designer

    Quote Originally Posted by impeteperry
    do I have to add anything to "label.h" ?
    No, the problem is with this line:
    Qt Code:
    1. Ui::label ui;
    To copy to clipboard, switch view to plain text mode 
    Open that .ui file in the Designer, select your form in the "Object Inspector" and check the value of objectName property in "Property Editor". It should be that same as the part after Ui:: (i.e. in this case it should be label).

  11. #11
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qt 3 program & Qt4 designer

    Thanks. it worked.!!!
    how simple things are when you know what you are doiing.

    Thanks again.

  12. #12
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qt 3 program & Qt4 designer

    A new problem. In the "Evolution of Qt Designer" there are 3 methods of connecting a ".ui" file. The first of the three is the one you helped me with, but the other two both have a problem.
    In the single-inheritance approach, you subclass the form's base class (QWidget or QDialog, for example), and include a private instance of the form's user interface object. For example:

    #ifndef MYFORM_H
    #define MYFORM_H

    #include "ui_myform.h"

    class MyForm : public QDialog
    {
    Q_OBJECT

    public:
    MyForm(QWidget *parent = 0) : QDialog(parent)
    { ui.setupUi(this);

    private slots:
    void on_inputSpinBox_valueChanged(int value);

    private:
    Ui::MyForm ui;
    };

    #endif
    it seems to be missing a "}". The third one is also missing one. This my attempt:
    #ifndef LABEL_H
    #define LABEL_H

    #include "ui_label.h"
    #include <QWidget>

    class Label : public QWidget
    {
    Q_OBJECT

    public:
    Label(QWidget *parent = 0) : QWidget(parent)
    { ui.setupUi(this);

    private slots:

    private:
    Ui::Label ui;
    };
    #endif
    and here is my message
    label.cpp:30: error: ‘Label::Label(QWidget*)’ cannot be overloaded
    label.h:35: error: with ‘Label::Label(QWidget*)’
    label.cpp:34: error: expected `}' at end of input
    label.h: In constructor ‘Label::Label(QWidget*)’:
    label.h:36: error: ‘ui’ was not declared in this scope
    label.h:38: error: expected primary-expression before ‘private’
    label.h:38: error: expected `;' before ‘private’
    label.cpp: At global scope:
    label.cpp:34: error: expected unqualified-id at end of input
    make: *** [label.o] Error 1
    my "label.cpp" is
    #include <QtGui>
    #include "label.h"

    Label::Label(QWidget *parent)
    : QWidget(parent)
    {
    }
    Thanks for any help.

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt 3 program & Qt4 designer

    Quote Originally Posted by impeteperry
    it seems to be missing a "}".
    Yes, that } should be there. Besides you can't implement the same method twice (you have implemented the constructor in both .h and .cpp file).

    It should be:

    label.h
    Qt Code:
    1. #ifndef LABEL_H
    2. #define LABEL_H
    3.  
    4. #include "ui_label.h"
    5. #include <QWidget>
    6.  
    7. class Label : public QWidget
    8. {
    9. Q_OBJECT
    10. public:
    11. Label( QWidget *parent = 0 );
    12.  
    13. private:
    14. Ui::Label ui;
    15. };
    16.  
    17. #endif
    To copy to clipboard, switch view to plain text mode 
    label.cpp:
    Qt Code:
    1. #include "label.h"
    2.  
    3. #include <QtGui>
    4.  
    5. Label::Label( QWidget *parent )
    6. : QWidget( parent )
    7. {
    8. ui.setupUi( this );
    9. }
    To copy to clipboard, switch view to plain text mode 

    PS. Next time, please, use [ code ] tags, instead of [ quote ] for code snippets.

  14. #14
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qt 3 program & Qt4 designer

    Thanks, will do.

    That did the job. I have now printed out the whole doc. wich I shall study in detail.
    I have three other programs that I need to convert. All my programs thou on drastically differnt subjects use the same basic type of layout ( I hate "blender"'s complexity all though I use it ).
    I really appreciate the help you have given me.

  15. #15
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qt 3 program & Qt4 designer

    I am using te "books" demo that comes with qt4 as a guide.

    I have all my widgets entered, layed out etc. As long as I don't set the whole shebang to a "layout on a grid" all is good except it doesn't "resize". If I do set it to a Grid, I just get a white box in the upper left corner.

    The "books" demo has a container labeled "QWidget" which performs the function I want to do with the "layout on a grid". I can't find a "QWidget" in the "containers" list.
    Any help would be appreciated

    PS:
    I have set up
    edpform.cpp edpform.h edpform.ui main.cpp
    as a template for my four programs. where I use a different "edpform.ui" for each program.
    Any thoughts?

  16. #16
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qt 3 program & Qt4 designer

    I don't know how, but I have solved my proklem

Similar Threads

  1. Threads in Designer plugins
    By hvengel in forum Qt Tools
    Replies: 2
    Last Post: 3rd January 2009, 19:19
  2. Program does not appear in TaskBar
    By Arsenic in forum Qt Programming
    Replies: 2
    Last Post: 21st July 2008, 21:06
  3. In what order do you create program pieces?
    By Backslash in forum Newbie
    Replies: 2
    Last Post: 15th July 2007, 18:18
  4. QT MySQL
    By sabeeshcs in forum Newbie
    Replies: 6
    Last Post: 12th January 2007, 04:19
  5. Replies: 13
    Last Post: 15th December 2006, 11:52

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.