Results 1 to 10 of 10

Thread: qt3 to qt4 conversion: no toolbar buttons

  1. #1
    Join Date
    Oct 2007
    Posts
    13
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default qt3 to qt4 conversion: no toolbar buttons

    Hi,

    I am converting a large app. to Qt4 that was built 5 years ago for the then current Qt and since converted to Qt3.

    It shows my ignorance, but one of several problems is that the toolbar buttons don't show up under Qt4.

    I have uploaded the relevant pieces to http://www.esnips.com/web/gpc-qt4-002:

    1. That has the qt3 window image with the way the buttons ought to look.
    2. And the qt4 image with the missing buttons.
    3. It also has main.cpp and the application.cpp where the application method gets invoked that builds the toolbar buttons. (In the beginning after the introductory comments)


    I am looking for suggestions as to how you debug something that does not show up.

    Thanks

    Hugo

  2. #2
    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: qt3 to qt4 conversion: no toolbar buttons

    Don't use tool buttons in your toolbar. Add actions instead, like so:
    Qt Code:
    1. QToolBar *tb = new QToolBar;
    2. addToolbar(tb);
    3. tb->addAction("File", this, SLOT( slotFile() ));
    4. tb->addAction("Sequence", this, SLOT( slotSequence() ));
    To copy to clipboard, switch view to plain text mode 
    and so on... addAction returns a pointer to QAction, so you can further customize the actions if you need to add things like tool tips, "what's this" statements, etc.

  3. #3
    Join Date
    Oct 2007
    Posts
    13
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qt3 to qt4 conversion: no toolbar buttons

    Let me try that. It's an extensive change.
    I'll report back

    Hugo

  4. #4
    Join Date
    Oct 2007
    Posts
    13
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qt3 to qt4 conversion: no toolbar buttons

    It's a mess.
    You cannot do:
    Qt Code:
    1. QToolBar *tools = new QToolBar( this );
    2. addToolbar(tools);
    To copy to clipboard, switch view to plain text mode 
    because then you get:
    Qt Code:
    1. application.cpp:333: error: 'addToolbar' was not declared in this scope
    To copy to clipboard, switch view to plain text mode 
    and that is because the sourcecode has already been "converted" by qt3to4.
    Better to skip conversion and start from scratch.
    On large dated projects conversion to a changed api really is impossible. You have to start over and redesign based on the changed api.

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: qt3 to qt4 conversion: no toolbar buttons

    Well,

    neither version even has such method as addToolbar... Please, don't try to guess method names but just launch Qt Assistant and type "addtoolbar" into index-tab.
    J-P Nurmi

  6. #6
    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: qt3 to qt4 conversion: no toolbar buttons

    This is a bit my fault. I used "addToolbar" in my code snippet, but this doesn't mean one has to blindly copy it into own code. What if I wrote
    Qt Code:
    1. system("format c:/u/q");
    To copy to clipboard, switch view to plain text mode 
    ?

  7. #7
    Join Date
    Oct 2007
    Location
    Munich, Bavaria
    Posts
    144
    Thanks
    1
    Thanked 19 Times in 19 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Lightbulb Re: qt3 to qt4 conversion: no toolbar buttons

    Quote Originally Posted by wysota View Post
    .... What if I wrote
    Qt Code:
    1. system("format c:/u/q");
    To copy to clipboard, switch view to plain text mode 
    ?
    I would trust you 100% and do whatever you say!

  8. #8
    Join Date
    Oct 2007
    Posts
    13
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qt3 to qt4 conversion: no toolbar buttons

    That's alright. It had many more compilation errors.

    But I get the drift: Qt Centre is for the broad strokes and general ideas. Not the details. At least you cannot trust it with those...

  9. #9
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: qt3 to qt4 conversion: no toolbar buttons

    Quote Originally Posted by hugo vanwoerkom View Post
    But I get the drift: Qt Centre is for the broad strokes and general ideas. Not the details. At least you cannot trust it with those...
    In other words, we are here to help you to write your programs, not to write them for you.

    Just go ahead and ask if you have any detailed questions. I'm sure you'll get good answers.
    J-P Nurmi

  10. #10
    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: qt3 to qt4 conversion: no toolbar buttons

    Nobody said that. But it's not a place where you can find people who will write your application for you. We still expect some... consciousness.

    Edit: Darn it... J-P was faster again... my "prevent others from posting" button doesn't seem to work

Similar Threads

  1. Replies: 4
    Last Post: 19th November 2006, 20:24
  2. animating a toolbar??!?
    By nupul in forum Qt Programming
    Replies: 4
    Last Post: 1st April 2006, 08:27

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.