Results 1 to 6 of 6

Thread: How do I make an executable file from a .ui designer file

  1. #1
    Join Date
    Feb 2010
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How do I make an executable file from a .ui designer file

    Hi,

    I'm new to Qt. I've successfully installed version 4.6.1 on my Linux system and compiled all the libraries. I've also gone into Designer and have created a sample .ui file.

    Now I'm lost and confused on how exactly to create an executable file. I've gone through the documentation using Assistant many times and am not getting anywhere. I'm sure uic, qmake and mabe moc have something to do with successfully creating an executable. But can't figure out exactly what I'm suppose to do. Is there a set of explicit instructions on exactly what to do once you have a .ui file to create an executable? I can't find it anywhere. There is talk of creating project files and options here and there, but no step by step instructions on exactly what to do after you have a .ui file. How can I create a .cpp file?

    any help would be greatly appreciated.

    thank you in advance,
    Zareh

  2. #2
    Join Date
    Feb 2010
    Posts
    61
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How do I make an executable file from a .ui designer file

    After u create a .ui file
    Build it either using the tools in Designer or ShortCut key:Ctrl + Shift + B to build and to run Ctrl + R
    or u can also generate .cpp files through the terminal but it is a big Procedure.
    try the earlier way if not i wil post the next details.

    Happy building!

  3. #3
    Join Date
    Feb 2010
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How do I make an executable file from a .ui designer file

    Quote Originally Posted by qtlinuxnewbie View Post
    After u create a .ui file
    Build it either using the tools in Designer or ShortCut key:Ctrl + Shift + B to build and to run Ctrl + R
    or u can also generate .cpp files through the terminal but it is a big Procedure.
    try the earlier way if not i wil post the next details.

    Happy building!
    Thank you for your reply. I can find the Ctrl + R option under the Form menu. It works and allows me to see a running version of my GUI. But I can't find the Ctrl + Shift + B option anywhere in Designer. Where and under what menu is the Ctrl + Shift + B located in Designer.

    Thanks again,
    Zareh

  4. #4
    Join Date
    Feb 2010
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How do I make an executable file from a .ui designer file

    Yay! I got it to compile and run!
    OK, here is how to go from a .ui file (and only a .ui file) to a usable executable in Linux.

    Step 1: Let's say your .ui file creates a color picker, in my case I called it ZarehsQtColorPicker.ui
    Go to the folder where your .ui file is and type the following command:
    > uic -o ZarehsQtColorPicker.h ZarehsQtColorPicker.ui
    make sure you're running the correct version of uic. You can specify it's path explicitly if you need to by typing it out, in my case it was something like this: ../../Linux_x86-2010.01/qt-everywhere-opensource-src-4.6.1/bin/uic -oZarehsQtColorPicker.h ZarehsQtColorPicker.ui

    At the end of this step you should have a .h file.

    Step 2: You have to create a .pro file (Project file). Here is what mine looks like:
    CONFIG += qt
    HEADERS += ZarehsQtColorPicker.h
    SOURCES += main.cpp

    Just go into emacs, vi or any text editor you like and type the above 3 lines and save the file. I called my file ZarehsQtColorPicker.pro
    You also need to make a main.cpp file. Here is what it should look like:
    #include "ZarehsQtColorPicker.h"

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

    QWidget *widget = new QWidget;

    Ui::ZarehsColorPicker ui;
    ui.setupUi(widget);

    widget->show();
    return app.exec();
    }

    The only things you need to change are the things colored in green. Just substitute whatever .h file and class name you are using in your example.
    OK, now that you have a .pro and a main.cpp file, type this command at the command prompt, making sure you're still in the directory where your .ui and .h file is:
    > qmake -o Makefile ZarehsQtColorPicker.pro


    Step 3: now you should have a file called "Makefile" in your directory. At the command prompt type make.
    > make

    that's it. you should now have an executable file in your directory. In my case it's called ZarehsQtColorPicker. I typed
    > ./ZarehsQtColorPicker
    at the command prompt and it executed and brought up the GUI designed in Designer.

    Hope this helps someone out there,
    Zareh

  5. #5
    Join Date
    Aug 2011
    Posts
    35
    Thanks
    5

    Default Re: How do I make an executable file from a .ui designer file

    Hey thanks, this helped me. But i was wondering, how would i have an icon on my desktop from which i could execute the application.

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How do I make an executable file from a .ui designer file

    how would i have an icon on my desktop from which i could execute the application.
    It isn't magic. You (or your installer for deployment) have to create one.

    The instructions from qtlinuxnewbie are for Qt Creator, which embeds Designer into a full C++ IDE.

Similar Threads

  1. Replies: 5
    Last Post: 15th June 2010, 07:42
  2. How to Create Executable file for my QT application
    By c_srikanth1984 in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2009, 04:02
  3. How to make qpf file
    By noufalk in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 10th March 2008, 21:16
  4. Replies: 1
    Last Post: 14th February 2008, 07:14
  5. Replies: 3
    Last Post: 25th May 2007, 07:49

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.