Discussion Board

Results 1 to 9 of 9
  1. #1
    Regular Contributor mkhpad's Avatar
    Join Date
    Nov 2011
    Posts
    104
    Hi,
    I am new to Qt and I have created a QComboBox which consists of 5 items inside it.

    What i am looking for is if the user clicks anyone of those items for example:if the user clicks the first item the page should drop down and displays the information about the first item.Hope everyone understood what i am trying to say.

    Can anyone say me what is the next step i need to do so that i can get displayed the information..?
    Here is my code:

    #include "mainwindow.h"

    #include <QtGui/QApplication>
    #include<QComboBox>
    #include<QHBoxLayout>



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

    QWidget *win =new QWidget;
    QHBoxLayout *layout = new QHBoxLayout;
    QComboBox *combo = new QComboBox();


    combo->addItem("A");
    combo->addItem("B");
    combo->addItem("C");
    combo->addItem("D");

    layout->addWidget(combo);
    win->setLayout(layout);
    win->showMaximized();

    return app.exec();
    }

    I am getting the combobox displayed with the 4 items which i had declared.I need to hold some information in A,B,C,D list items.

    How to create information in list items and how to display those when clicked on anyone of those items?

    Waiting for the reply.

    Regards,
    Harish.
    Last edited by mkhpad; 2011-11-19 at 11:15.

  2. #2
    Hi
    you can use the signal currentIndexChanged(int), that give you index of current row. and then set tooltip for this row.

    connect(combo, SIGNAL(currentIndexChanged(int)), this, SLOT(setItemToolTip(int)));

    void seItemToolTip(int index)
    {
    combo->setToolTip(tr("It is row %1.").arg(index));
    }

  3. #3
    Nokia Developer Champion rahulvala's Avatar
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,293
    You have not used signal and slot , try to implement it with label.

    How to use QComboBox

    regards,
    rahul

  4. #4
    Regular Contributor mkhpad's Avatar
    Join Date
    Nov 2011
    Posts
    104
    I tried using Qlabel but i am expecting when anyone of those items is selected/clicked it must dropdown and display some text in the form of information and not in a label.

  5. #5
    Nokia Developer Champion savaj's Avatar
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034
    What about ToolTips as mentioned in #2?

  6. #6
    Regular Contributor mkhpad's Avatar
    Join Date
    Nov 2011
    Posts
    104
    I tried using setToolTip and i dont know when and where to use?Could you help me?I have tried in this way am i correct if wrong guide me..!

    combo->addItem("A");


    combo->addItem("B");


    combo->addItem("C");


    combo->setToolTip(QObject::tr("Here comes A").arg(0));
    combo->setToolTip(QObject::tr("Here comes B").arg(1));
    combo->setToolTip(QObject::tr("Here comes C"). arg(2));
    QObject::connect(combo, SIGNAL(currentIndexChanged(int)),, SLOT(setItemToolTip(int)));

  7. #7
    Nokia Developer Expert Fuzzbender's Avatar
    Join Date
    Feb 2008
    Posts
    183
    AFAIK, tooltips don't work in Qt/Symbian: https://bugreports.qt.nokia.com/browse/QTBUG-9028

  8. #8
    Regular Contributor mkhpad's Avatar
    Join Date
    Nov 2011
    Posts
    104
    Hi,
    Could you say me in my code where i have to use this tooltip?Where i have to enter the text which i like to enter?

  9. #9
    Regular Contributor mkhpad's Avatar
    Join Date
    Nov 2011
    Posts
    104
    Hi,
    I dont want to use tooltip because i am expecting for nly if the user clicks the item it should display a paragraph of text about it in a dropdown box and not as a tool tip.

Similar Threads

  1. Display information about an item
    By david.morgan in forum Symbian User Interface
    Replies: 3
    Last Post: 2010-07-02, 09:46
  2. cell information display
    By anigma.55 in forum Geolocation and Navigation
    Replies: 5
    Last Post: 2008-08-19, 17:11
  3. Display help information for an application
    By asheeshv in forum Symbian C++
    Replies: 1
    Last Post: 2005-04-21, 07:53

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved