Results 1 to 3 of 3

Thread: Generating header files from ui files with uic

  1. #1
    Join Date
    Sep 2010
    Posts
    25
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Generating header files from ui files with uic

    Hi there,

    I'm just following examples from Jasmin Blanchette's book "C++ GUI Programming with Qt 4" Second Edition, which seems to be very good so far. The only area I'm having any difficulty with is using Qt Designer to generate C++ header files.

    In the gotocelldialog example, from Chapter 2, when I run qmake -project & qmake gotocell.pro the ui_gotocelldialog.h file is not created. I've searched on my system and it didn't appear in any other path either.

    I am running the latest 2010.05 realease of the Qt SDK on Windows XP SP3 under the LGPL license (although my license knowledge is somewhat limited)

    I think my main.cpp file is the same as the example

    Qt Code:
    1. #include <QApplication>
    2. #include <QDialog>
    3. #include "ui_gotocelldialog.h"
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication app(argc, argv);
    7.  
    8. Ui::GoToCellDialog ui;
    9. QDialog *dialog = new QDialog;
    10. ui.setupUi(dialog);
    11. dialog->show();
    12.  
    13. return app.exec();
    14. }
    To copy to clipboard, switch view to plain text mode 

    The example files show a ui file as follows:

    Qt Code:
    1. <ui version="4.0" >
    2. <class>GoToCellDialog</class>
    3. <widget class="QWidget" name="GoToCellDialog" >
    4. <property name="geometry" >
    5. <rect>
    6. <x>0</x>
    7. <y>0</y>
    8. <width>190</width>
    9. <height>94</height>
    10. </rect>
    11. </property>
    12. <property name="windowTitle" >
    13. <string>Go to Cell</string>
    14. </property>
    15. <layout class="QVBoxLayout" >
    16. <item>
    17. <layout class="QHBoxLayout" >
    18. <item>
    19. <widget class="QLabel" name="label" >
    20. <property name="text" >
    21. <string>&amp;Cell Location:</string>
    22. </property>
    23. <property name="buddy" >
    24. <cstring>lineEdit</cstring>
    25. </property>
    26. </widget>
    27. </item>
    28. <item>
    29. <widget class="QLineEdit" name="lineEdit" />
    30. </item>
    31. </layout>
    32. </item>
    33. <item>
    34. <layout class="QHBoxLayout" >
    35. <item>
    36. <spacer>
    37. <property name="orientation" >
    38. <enum>Qt::Horizontal</enum>
    39. </property>
    40. <property name="sizeHint" >
    41. <size>
    42. <width>40</width>
    43. <height>20</height>
    44. </size>
    45. </property>
    46. </spacer>
    47. </item>
    48. <item>
    49. <widget class="QPushButton" name="okButton" >
    50. <property name="enabled" >
    51. <bool>false</bool>
    52. </property>
    53. <property name="text" >
    54. <string>OK</string>
    55. </property>
    56. <property name="default" >
    57. <bool>true</bool>
    58. </property>
    59. </widget>
    60. </item>
    61. <item>
    62. <widget class="QPushButton" name="cancelButton" >
    63. <property name="text" >
    64. <string>Cancel</string>
    65. </property>
    66. </widget>
    67. </item>
    68. </layout>
    69. </item>
    70. </layout>
    71. </widget>
    72. <tabstops>
    73. <tabstop>lineEdit</tabstop>
    74. <tabstop>okButton</tabstop>
    75. <tabstop>cancelButton</tabstop>
    76. </tabstops>
    77. <resources/>
    78. <connections/>
    79. </ui>
    To copy to clipboard, switch view to plain text mode 

    my ui file is as follows

    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <ui version="4.0">
    3. <class>GoToCellDialog</class>
    4. <widget class="QWidget" name="GoToCellDialog">
    5. <property name="geometry">
    6. <rect>
    7. <x>0</x>
    8. <y>0</y>
    9. <width>250</width>
    10. <height>71</height>
    11. </rect>
    12. </property>
    13. <property name="windowTitle">
    14. <string>Go to Cell</string>
    15. </property>
    16. <layout class="QVBoxLayout" name="verticalLayout">
    17. <item>
    18. <layout class="QHBoxLayout" name="horizontalLayout">
    19. <item>
    20. <widget class="QLabel" name="label">
    21. <property name="text">
    22. <string>&amp;Cell Location:</string>
    23. </property>
    24. <property name="buddy">
    25. <cstring>lineEdit</cstring>
    26. </property>
    27. </widget>
    28. </item>
    29. <item>
    30. <widget class="QLineEdit" name="lineEdit"/>
    31. </item>
    32. </layout>
    33. </item>
    34. <item>
    35. <layout class="QHBoxLayout" name="horizontalLayout_2">
    36. <item>
    37. <spacer name="horizontalSpacer">
    38. <property name="orientation">
    39. <enum>Qt::Horizontal</enum>
    40. </property>
    41. <property name="sizeHint" stdset="0">
    42. <size>
    43. <width>68</width>
    44. <height>20</height>
    45. </size>
    46. </property>
    47. </spacer>
    48. </item>
    49. <item>
    50. <widget class="QPushButton" name="okButton">
    51. <property name="enabled">
    52. <bool>false</bool>
    53. </property>
    54. <property name="text">
    55. <string>OK</string>
    56. </property>
    57. <property name="default">
    58. <bool>true</bool>
    59. </property>
    60. </widget>
    61. </item>
    62. <item>
    63. <widget class="QPushButton" name="cancelButton">
    64. <property name="text">
    65. <string>Cancel</string>
    66. </property>
    67. </widget>
    68. </item>
    69. </layout>
    70. </item>
    71. </layout>
    72. </widget>
    73. <tabstops>
    74. <tabstop>lineEdit</tabstop>
    75. <tabstop>okButton</tabstop>
    76. <tabstop>cancelButton</tabstop>
    77. </tabstops>
    78. <resources/>
    79. <connections/>
    80. </ui>
    To copy to clipboard, switch view to plain text mode 

    There seems to be something going on with

    Qt Code:
    1. 1.<?xml version="1.0" encoding="UTF-8"?>
    To copy to clipboard, switch view to plain text mode 

    Any ideas why Qt Designer is generating this difference, or if it is an issue?

  2. #2
    Join Date
    Sep 2010
    Posts
    25
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Generating header files from ui files with uic

    Ahhh I see. Sorry for the newbie comment. The header file is generated after running make. This certainly isn't clear in the book though.

    Anyway at least it got me to post something. Hopefully my next post will be more worthwhile.

  3. #3
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Generating header files from ui files with uic

    And there are errors with that include when you run nmake, or mingw32-make if you use the SDK, which comes with mingw compiler?
    EDIT: too late

Similar Threads

  1. How to add external Header files and libraries?
    By askbapi in forum Installation and Deployment
    Replies: 6
    Last Post: 30th September 2010, 17:33
  2. Replies: 2
    Last Post: 5th September 2010, 14:26
  3. Generating Log files
    By srohit24 in forum Qt Programming
    Replies: 12
    Last Post: 15th July 2009, 07:57
  4. header files problems
    By dognzhe in forum General Programming
    Replies: 1
    Last Post: 18th May 2009, 08:00
  5. header files not getting included
    By nimmyj in forum Installation and Deployment
    Replies: 1
    Last Post: 19th December 2006, 06:18

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.