×

Discussion Board

Results 1 to 3 of 3

Thread: Button in Qt

  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    1

    Wink Button in Qt

    IDE : QT Creator
    I've added the pictures file in my project path , I can see them I read about Qt Documentation and write the following line code but it doesn't work on with the emulator why ? Can someone help me ?
    bouton.setIcon(QIcon( QCoreApplication::applicationDirPath() +"/blink.png"));

    I also want to give ability to my second button
    autreBouton.move(30, 15);

    thanks folks




    #include <QApplication>
    #include <QtGui>


    //#include <QSystemInfo> //(1)
    #include <QPushButton>

    //QTM_USE_NAMESPACE //(2)

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


    // Création d'un widget qui servira de fenêtre
    QWidget fenetre;
    fenetre.setFixedSize(400, 350);

    // Création du bouton, ayant pour parent la "fenetre"
    QPushButton bouton("Pimp mon bouton !", &fenetre);


    bouton.setToolTip("Texte D'aide"); //Texte
    bouton.setFont(QFont("Courrier", 10, QFont::Bold, true)); //Font
    bouton.setCursor(Qt::PointingHandCursor); //cursor de souris
    //bouton.setIcon(QIcon(QCoreApplication::applicationDirPath()+"img/tux2.png")); //Icon on Button
    bouton.setIcon(QIcon( QCoreApplication::applicationDirPath() +"/blink.png"));


    // Création d'un autre bouton ayant pour parent le premier bouton
    QPushButton autreBouton("Autre bouton", &bouton);

    autreBouton.move(30, 15);



    fenetre.show();

    // QSystemInfo s;
    // QLabel *label = new QLabel(QObject::tr("hello ").append(s.currentCountryCode()));
    // label->show();
    // label->resize(100,30);


    #if defined(Q_WS_S60)
    fenetre.showMaximized();
    #else
    fenetre.show();
    #endif

    return app.exec();
    }



    The Pro File

    TEMPLATE = app
    TARGET =
    DEPENDPATH += .
    INCLUDEPATH += .
    QT += network

    CONFIG += mobility
    MOBILITY += systeminfo

    # Input
    SOURCES += main.cpp

    symbian {
    TARGET.CAPABILITIES = LocalServices ReadUserData WriteUserData NetworkServices UserEnvironment Location ReadDeviceData
    }

    OTHER_FILES += \
    ./blink.png \
    img/tux2.png \
    img/tux.jpg
    Last edited by promachos; 2010-08-01 at 22:11.

  2. #2
    Super Contributor
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,326

    Re: Button in Qt

    Welcome to the Forum nokia DIBo.

    Function to set icon in the button is here : button->setIcon(QIcon("c://name.png"));

    Also visit this article : How to set icon in the button.

    Best regards,
    RaHuL

  3. #3
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Button in Qt

    It's often useful, when you have a cascade of nested calls/constructors, to break the calls into individual lines such that you can observe/test the result at each stage. Often when there's an error loading a file the problem is a poorly constructed file path, or a misinterpretation of the file structure on the device.

Similar Threads

  1. Replies: 8
    Last Post: 2010-05-20, 18:22
  2. QT TextBox after pressed a button
    By JM30 in forum Qt
    Replies: 3
    Last Post: 2010-03-25, 15:37

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×