Results 1 to 13 of 13

Thread: How to create .ui file from hand written header and source files only.

  1. #1
    Join Date
    Mar 2011
    Location
    Narvik, Norway
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default How to create .ui file from hand written header and source files only.

    Hi everyone,
    As I write this message I am in the middle of my big student project involving a lot of coding in Qt, and I have stumbled over a matter that I needed some help with.
    As of today, all my code is in header and source files only, and I never even opened Qt Designer. The issue is, I need to be able to move my buttons around, and rescale some of it, and doing this by hand can be quite hard and time consuming, seeing that I don't have much time left before my deadline.

    As of today I have 16 source files, and 16 headers, and when I build it it pops up almost as I want it. All I need to do, is insert some custom buttons instead of the boring gray ones, and rearrange them a bit so the final result looks better for the user.

    So, I guess my final question is: "how do I create a .ui file where I can arrange everything as I want, but create it from the sources I already have (not a new project)"

    I really hope there is a quick solution somewhere that I overlooked. (I'm a Newbie when it comes to Qt)

    yours truly,
    Badeand

  2. #2
    Join Date
    Feb 2011
    Location
    Latvia
    Posts
    139
    Thanks
    24
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to create .ui file from hand written header and source files only.

    RMB on the project name on the left, then Add New -> Qt -> Qt Designer Form...
    But I cannot be sure that this is what u want...

  3. #3
    Join Date
    Mar 2011
    Location
    Narvik, Norway
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to create .ui file from hand written header and source files only.

    Hi, thanks for answering =)
    No, this just creates a new blank UI, what I want is to create THE UI, from my source files, so that what I see when I build my project, is what I will see on my UI form (that doesn't exist yet).
    So I want to somehow port my program to a more editable state.

    Hope you understand,
    Badeand

  4. #4
    Join Date
    Feb 2011
    Location
    Latvia
    Posts
    139
    Thanks
    24
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to create .ui file from hand written header and source files only.

    Hm... But is this even possible? I think not...

  5. #5
    Join Date
    Mar 2011
    Location
    Narvik, Norway
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to create .ui file from hand written header and source files only.

    I really hope so, cause if it ain't I have A LOT of work to do... I need to somehow implement custom buttons (made by me in Photoshop), and move them where I want them to be, and a lot of other Design stuff, to make my program more attractive.

  6. #6
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: How to create .ui file from hand written header and source files only.

    Designer work only flows one way - from Designer to UI files to C++ files, with a few intermediate steps along the way. You can't get Designer to ingest existing C++ files and understand the layouts. At this point, you'll have to make your changes by hand.

    Note for the future: always keep your UI code separate from your program's guts. You never know when a new UI might be required, and if someone comes along and demands, say, a Java front end then all you have to do is rewrite that and not the entire program. In your particular case, you could have turned to the Designer and grafted its output onto your backend without much trouble. Too late now, from the sounds of it, but something to keep in mind for next time.

  7. #7
    Join Date
    Mar 2011
    Location
    Narvik, Norway
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to create .ui file from hand written header and source files only.

    Actually my Ui code is in a separate source, called mainwindow.cpp and mainwindow.h, does this help? The thing is its a program that moves from person to person over the years, so I am working on someone else's work, and every year a new person takes over and "makes it better". Its a student engineering project to show us what will happend to us when we get out working =)

  8. #8
    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: How to create .ui file from hand written header and source files only.

    I have a tool that is more or less able to do it but at a current state it would require your dialogs to use layouts which I doubt they do, if I correctly interpret what you say. Besides the tool is not free. I could probably do the translation for you but not for free.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Mar 2011
    Location
    Narvik, Norway
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to create .ui file from hand written header and source files only.

    I think I use layouts =)
    Example1:
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent)
    2. : QMainWindow(parent), mdir("messages.txt")
    3. {
    4.  
    5. QTabWidget* tabw = new QTabWidget;
    6. QWidget* cpwidget = new QWidget;
    7. QVBoxLayout* playout = new QVBoxLayout;
    8. QGridLayout* pgrid = new QGridLayout;
    9.  
    10. socket = new LHCPSocket;
    11. QWidget* cwidget = new QWidget;
    12. QVBoxLayout* toplayout = new QVBoxLayout;
    13. QGridLayout* grid = new QGridLayout;
    To copy to clipboard, switch view to plain text mode 

    Example2:
    Qt Code:
    1. toplayout->addWidget(new ConnectBar(socket,mdir.getMsgInfo("SHUTDOWN_SERVER")));
    2. toplayout->addWidget(map);
    3. toplayout->addWidget(supportb);
    To copy to clipboard, switch view to plain text mode 

    Due to copyright material I can't post more "explaining" code... but maby this helped you a bit?

  10. #10
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: How to create .ui file from hand written header and source files only.

    Quote Originally Posted by Badeand View Post
    Actually my Ui code is in a separate source, called mainwindow.cpp and mainwindow.h, does this help? The thing is its a program that moves from person to person over the years, so I am working on someone else's work, and every year a new person takes over and "makes it better". Its a student engineering project to show us what will happend to us when we get out working =)
    Designer, though, only understands UI files and the XML they contain. It cannot ingest C++ code, and there is no tool I'm aware of that can produce UI files from such code (apart from wysota's tool, mentioned above).

    You can either A) modify your existing code by hand to make it match desired appearances, or B) create a brand new GUI using Designer, then extend the Designer-produced classes and call your backend from there.

  11. The following user says thank you to SixDegrees for this useful post:

    Badeand (22nd March 2011)

  12. #11
    Join Date
    Mar 2011
    Location
    Narvik, Norway
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to create .ui file from hand written header and source files only.

    Ok thanks guy, I guess I will just do it by hand then, but do you know if there is any way to use custom buttons that way? I heard something about a program called Qt Quick Designer, but maby thats not it.

  13. #12
    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: How to create .ui file from hand written header and source files only.

    Yeah, I should be able to do the translation although we might have a problem with those custom widgets of yours. It's not a show-stopper though. With a bit of manual editing it should be fine. Of course for example line #1 of your second snippet is not possible to be fully translated to ui. You'd need a default constructor for your ConnectBar widget. Note though I need to be able to run your application in order to do the translation.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  14. The following user says thank you to wysota for this useful post:

    Badeand (22nd March 2011)

  15. #13
    Join Date
    Mar 2011
    Location
    Narvik, Norway
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to create .ui file from hand written header and source files only.

    Quote Originally Posted by wysota View Post
    Yeah, I should be able to do the translation although we might have a problem with those custom widgets of yours. It's not a show-stopper though. With a bit of manual editing it should be fine. Of course for example line #1 of your second snippet is not possible to be fully translated to ui. You'd need a default constructor for your ConnectBar widget. Note though I need to be able to run your application in order to do the translation.
    I would love this, but unfortunately I am not allowed to share my code with anyone (I had to sign a lot of documents when I started working with this) so I guess I am on my own here, but thanks for trying to help.

Similar Threads

  1. How to create an animated GIF file with some BMP files?
    By accordionist in forum General Programming
    Replies: 2
    Last Post: 30th December 2010, 12:25
  2. How to create an animated GIF file with some BMP files?
    By accordionist in forum Qt Programming
    Replies: 0
    Last Post: 30th December 2010, 06:48
  3. Replies: 2
    Last Post: 1st March 2010, 17:58
  4. qmake using source files not in .pro file
    By Asperamanca in forum Newbie
    Replies: 12
    Last Post: 9th July 2009, 15:29
  5. Adding QPushButton to *.ui file by hand
    By s410i in forum Qt Programming
    Replies: 3
    Last Post: 23rd June 2009, 13:08

Tags for this Thread

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.