Results 1 to 4 of 4

Thread: customized Combobox

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2014
    Posts
    22
    Thanks
    5
    Qt products
    Qt5

    Default customized Combobox

    Hi,
    i am interested to create a combo-box which should appear as shown below.
    double_combobox.png

    After "highlighting" the index_5 of first combobox i.e. "SiX_6", it should show a second combo-box near to that showing "Days".

    I have created a custom widget mycombobox, which contains the 1st combobox with data 'SiX_6', i have attached the signal of this combo box on highlight to a slot defined here, which checks if the selected index is 5, and in that slot, i am creating the 2nd combobox showing days.
    I am not able to see the 2nd combobox on screen.

    Is the way i am proceeding is correct? or what is the way to do this type of widget?

    thanks in advance.


    Qt Code:
    1. class myComboBox : public QWidget
    2. {
    3. Q_OBJECT
    4. public:
    5. explicit myComboBox(QWidget *parent = 0);
    6. ~myComboBox ();
    7.  
    8. signals:
    9.  
    10. public slots:
    11. void Activate_2nd_Box(int index);
    12.  
    13. protected:
    14. QComboBox *box;
    15. QLabel *label;
    16.  
    17. };
    18.  
    19.  
    20. myComboBox::myComboBox(QWidget *parent) :
    21. QWidget(parent)
    22. {
    23. QStringList dump_data;
    24. dump_data << "ONE_1" << "TWO_2" << "THREE_3" << "FouR_4" << "FivE_5" << "SiX_6";
    25. QComboBox *doublebox = new QComboBox(this);
    26. doublebox->addItems( dump_data );
    27.  
    28.  
    29. connect(doublebox, SIGNAL(highlighted(int)), this, SLOT(Activate_2nd_Box(int)));
    30. //connect(doublebox, SIGNAL(currentIndexChanged(int)), this, SLOT(Activate_2nd_Box(int)));
    31. }
    32.  
    33. myComboBox::~myComboBox()
    34. {
    35. delete box;
    36. delete label;
    37. }
    38.  
    39. void myComboBox::Activate_2nd_Box(int index)
    40. {
    41. if(index == 5)
    42. {
    43. qDebug() << "index : "<< index << " highlighted";
    44. data << "Sunday" << "Monday" << "Tuesday" << "Wednesday" << "Thursday" << "Friday" << "Saturday";
    45. QComboBox *box2 = new QComboBox(this);
    46. box2->addItems( data );
    47.  
    48. box2->show();
    49. }
    50. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 28th October 2014 at 13:27. Reason: changed [qtclass] to [code]

Similar Threads

  1. Problem with customized QTabWidget
    By SeanM in forum Qt Programming
    Replies: 2
    Last Post: 18th April 2014, 18:18
  2. customized QgraphicsItems Replaceing them self
    By prasad.ece2 in forum Qt Programming
    Replies: 0
    Last Post: 31st December 2013, 09:17
  3. customized layout issue
    By sanjayshelke in forum Qt Programming
    Replies: 1
    Last Post: 28th November 2008, 07:02
  4. QStyleOptionProgressBar customized
    By xEsk in forum Qt Programming
    Replies: 1
    Last Post: 11th November 2007, 17:25
  5. Customized Table
    By tunguska in forum Qt Programming
    Replies: 3
    Last Post: 28th September 2007, 17:44

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.