Results 1 to 10 of 10

Thread: What is the way to add numbers in sequence to the combo box in QtCreator?

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

    Default What is the way to add numbers in sequence to the combo box in QtCreator?

    I need to add numbers from 50 to 500 in this combo box. What's the way out without adding them manually by hand?
    qt.jpg

  2. #2
    Join Date
    Jan 2012
    Location
    Iran, Tehran
    Posts
    308
    Thanks
    75
    Thanked 24 Times in 21 Posts
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: What is the way to add numbers in sequence to the combo box in QtCreator?

    you can do this in code by a loop, ui->comboBox->addItem(i);

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

    Default Re: What is the way to add numbers in sequence to the combo box in QtCreator?

    I know that, but in this case I am using the creator. It generates a file called "showmap.ui".
    Where do I have to write code now?

  4. #4
    Join Date
    Jan 2012
    Location
    Iran, Tehran
    Posts
    308
    Thanks
    75
    Thanked 24 Times in 21 Posts
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: What is the way to add numbers in sequence to the combo box in QtCreator?

    .ui files are in xml format. I don't know a way to do this in qtcreator but in xml you can do this for example by copy and pasting from excel to xml in its correct format

  5. #5
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: What is the way to add numbers in sequence to the combo box in QtCreator?

    Add the code after showmap::setupUi();
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

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

    Default Re: What is the way to add numbers in sequence to the combo box in QtCreator?

    Quote Originally Posted by Santosh Reddy View Post
    Add the code after showmap::setupUi();
    Pardon my ignorance, but where do I have to find and write that?

  7. #7
    Join Date
    Jan 2012
    Location
    Iran, Tehran
    Posts
    308
    Thanks
    75
    Thanked 24 Times in 21 Posts
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: What is the way to add numbers in sequence to the combo box in QtCreator?

    Add the code after showmap::setupUi();
    setupUi() is in cpp, if you have it.

  8. #8
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: What is the way to add numbers in sequence to the combo box in QtCreator?

    Well you can edit the ui file, but this may take more effort than typing in the Qt Creator. Moreover it requires some insignt into ui file format / xml.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  9. #9
    Join Date
    Jan 2012
    Location
    Iran, Tehran
    Posts
    308
    Thanks
    75
    Thanked 24 Times in 21 Posts
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: What is the way to add numbers in sequence to the combo box in QtCreator?

    in qtCreator add QtDesignerFormClass then you have .h,.cpp beside .ui file. then in constructor you can find setupUI

  10. #10
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: What is the way to add numbers in sequence to the combo box in QtCreator?

    showmap.ui is a UI file, it generally will be included by a QWidget based class, and in the ctor of that QWidget a setupUi() will be used.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

Similar Threads

  1. every possible sequence
    By timmu in forum Qt Programming
    Replies: 3
    Last Post: 10th August 2012, 14:36
  2. show and resize sequence
    By Windsoarer in forum Qt Programming
    Replies: 2
    Last Post: 20th May 2012, 21:36
  3. Sequence images player
    By hhe in forum Qt Programming
    Replies: 1
    Last Post: 15th May 2010, 09:13
  4. Key sequence maximize program
    By bunjee in forum Qt Programming
    Replies: 2
    Last Post: 11th November 2009, 22:18
  5. Frame sequence
    By bmn in forum Qt Programming
    Replies: 7
    Last Post: 22nd May 2008, 22:57

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.