Results 1 to 4 of 4

Thread: help setting up qt4 ui from qt3

  1. #1
    Join Date
    Feb 2006
    Posts
    29
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Windows

    Default help setting up qt4 ui from qt3

    hi,

    i spent a load of time in qt3 building a ui file and then sublcassing the resulting generated files to be my main window. the procedure in qt4, however, is throwing me off.

    for example, i created test.ui, which (when compiled) generated test.h and test.cpp. i also added functions into test.ui.h, and the class name is called testClass (which is a QMainWindow sublcass).

    since i needed more functionality in the class, i subclassed testClass as testSubClass into files testSubClass.cpp and testSubClass.h. in main.cpp, i create an instance of testSubClass which acts as my main window.

    so far i have for qt3:
    files i created
    ---------------
    test.ui test.ui.h
    testSubClass.cpp
    testSubClass.h


    generated files
    ---------------------
    test.cpp, test.h

    and i define my testSubClass as
    Qt Code:
    1. class testSubClass : public testClass
    To copy to clipboard, switch view to plain text mode 

    i'm now trying to translate this into qt4's new and confusing ui structure.

    so far i have for qt4:
    files i created
    ---------------
    test.ui
    testSubClass.cpp
    <--- leftover from qt3 architecture. contains all the functionality
    testSubClass.h

    generated files
    ---------------------
    ui_test.h

    how do i define testSubClass now? is it a testClass subclass or a QMainWindow subclass or both?

    where does this new ui.setupUi() go, in main or in testSubClass.cpp in the testSubClass constructor?

    when do i use this Ui namespace??

    i've read the sparse documentation on making these changes and that's what got me this far, but i'm lost in getting past this.

    thanks!! -- lou

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: help setting up qt4 ui from qt3

    You can choose between either the single inheritance approach or the multiple inheritance approach. You can read about both of them in the documentation.

    Single inheritance:
    how do i define testSubClass now? is it a testClass subclass or a QMainWindow subclass or both?
    For this case is a subclass of QMainWindow and contains a member of type Ui::testClass( this is the one generated by uic ).
    when do i use this Ui namespace??
    Right there...
    where does this new ui.setupUi() go, in main or in testSubClass.cpp in the testSubClass constructor?
    Assuming you have something like Ui::testClass ui;, then ui.setupUi(this) goes in the constructor of the subclass, meaning testSubClass.

    The multiple inheritance approach assumes you subclass QMainWindow but also Ui::testClass. Then you have direct access to it's members.

    Regards

  3. #3
    Join Date
    Feb 2006
    Posts
    29
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: help setting up qt4 ui from qt3

    Quote Originally Posted by marcel View Post
    You can choose between either the single inheritance approach or the multiple inheritance approach. You can read about both of them in the documentation.

    Single inheritance:

    For this case is a subclass of QMainWindow and contains a member of type Ui::testClass( this is the one generated by uic ).

    Right there...

    Assuming you have something like Ui::testClass ui;, then ui.setupUi(this) goes in the constructor of the subclass, meaning testSubClass.

    The multiple inheritance approach assumes you subclass QMainWindow but also Ui::testClass. Then you have direct access to it's members.

    Regards
    hi, thanks for the reply. i read all the documentation multiple times, but it is sparse and does not give complete examples, just snippets, and it's especially useless for mainwindows using multiple inheritance. the docs don't discuss the advantages or disadvantages of either approach.

    single inheritance is the approach i was taking for converting things to qt4, but the single inheritance approach doesn't seem correct or in line with the way i worked things in qt3. as a subclass, i had access to all members of the base class, which is a necessity. with this single inheritance, i'd have to do so much reprogramming to point to the right members i'd rather become a monk.

    honestly i don't even see the benefit of the single inheritance approach. it looks like i have to have the multiple inheritance.

    so, i know how to inherit from both classes, but how do the ui::setup commands change for multiple inheritance?
    is there any drawback to using multiple inheritance?

    thanks again! -- lou

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: help setting up qt4 ui from qt3

    so, i know how to inherit from both classes, but how do the ui::setup commands change for multiple inheritance?
    is there any drawback to using multiple inheritance?
    Well, it changes to setupUi(this), since you inherit the class now, and it is not a member anymore.

    Regards.

Similar Threads

  1. Replies: 3
    Last Post: 30th January 2007, 07:35
  2. Setting style in QApplication
    By Doug Broadwell in forum Newbie
    Replies: 2
    Last Post: 28th October 2006, 21:56
  3. form setting
    By mickey in forum Qt Tools
    Replies: 5
    Last Post: 27th September 2006, 00:28
  4. setting desktop background and screensaver in X11
    By nupul in forum Qt Programming
    Replies: 5
    Last Post: 2nd April 2006, 21:11
  5. Replies: 4
    Last Post: 29th March 2006, 23:44

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.