Results 1 to 8 of 8

Thread: How to pass parameters to a .ui file in Qt?

  1. #1
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default How to pass parameters to a .ui file in Qt?

    For: http://doc.qt.nokia.com/4.7-snapshot...ml#setItemText
    I wrote:

    Qt Code:
    1. <widget class="QComboBox" name = "button55">
    2. <property name="ItemText">
    3. <number>0</number>
    4. <string>fontCombosBox</string>
    5. </property>
    6. </widget>
    To copy to clipboard, switch view to plain text mode 

    This results in:
    Qt Code:
    1. ui_showmap.h:73:109: error: no matching function for call to ‘QComboBox::setItemText(QString)’
    2. ../../../../qtsdk-2010.05/qt/include/QtGui/qcombobox.h:206:10: note: candidate is: void QComboBox::setItemText(int, const QString&)
    To copy to clipboard, switch view to plain text mode 

    I checked: http://www.kde.gr.jp/~ichi/qt/design...l-15.html#1-19

    Tried changing string to cstring. That didn't help either.

    What's the way out?

    P.S. Complier is g++ on openSUSE 11.3 with Qt 4.7

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to pass parameters to a .ui file in Qt?

    QComboBox::setItemTex takes 2 parameters, you're passing only one. The compilers complains on such invocation.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default Re: How to pass parameters to a .ui file in Qt?

    Quote Originally Posted by spirit View Post
    QComboBox::setItemTex takes 2 parameters, you're passing only one. The compilers complains on such invocation.
    I *did* pass two.
    First number, second string.

    Now, I saw this: http://doc.qt.nokia.com/4.7-snapshot...dialog-ui.html

    so the correct way is:

    Qt Code:
    1. <widget class="QComboBox" name="zoomLevel" >
    2. <item>
    3. <property name="text" >
    4. <string>5</string>
    5. </property>
    6. </item>
    7. </widget>
    To copy to clipboard, switch view to plain text mode 

    Question: Besides, qt functions also have parameter types as "QVariant". If I have to use those parameters what's the way out? Is there any proper documentation on .ui files?

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to pass parameters to a .ui file in Qt?

    Qt Designer has convenient QComboBox items editor. Why don't you use it instead of manually editing xml (ui) file?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. The following user says thank you to spirit for this useful post:

    TheIndependentAquarius (21st August 2012)

  6. #5
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default Re: How to pass parameters to a .ui file in Qt?

    I don't have it installed currently, that's why asked.

  7. #6
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to pass parameters to a .ui file in Qt?

    I'm sure you do. Check your QTDIR/bin folder. Or if you are using QtCreator there is the "Designer" tab in main window.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  8. The following user says thank you to spirit for this useful post:

    TheIndependentAquarius (21st August 2012)

  9. #7
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default Re: How to pass parameters to a .ui file in Qt?

    That's quite helpful. I opened the QtCreator and saw the designer tab. Indeed the .ui gets generated automatically. That's the reason perhaps that there is no proper documentation for it.

  10. #8
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to pass parameters to a .ui file in Qt?

    There is documentation but it's not a part of Qt's docs. It's part of the QtCreator's docs. See Developing Widget Based Applications.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

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

    TheIndependentAquarius (21st August 2012)

Similar Threads

  1. Replies: 2
    Last Post: 12th June 2010, 02:21
  2. Automatically setting up pro.user file parameters
    By purplecoast in forum Qt Tools
    Replies: 0
    Last Post: 23rd April 2010, 19:10
  3. Replies: 4
    Last Post: 3rd May 2009, 18:32
  4. Start a exe file with parameters
    By raphaelf in forum Qt Programming
    Replies: 11
    Last Post: 17th June 2008, 09:11
  5. Replies: 2
    Last Post: 16th August 2007, 00:20

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.