Discussion Board

Results 1 to 3 of 3

Thread: Button in Qt

  1. #1
    Registered User
    Join Date
    Jul 2010

    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>


    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);


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

    #if defined(Q_WS_S60)

    return app.exec();

    The Pro File

    TEMPLATE = app
    TARGET =
    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 \
    Last edited by promachos; 2010-08-01 at 22:11.

  2. #2
    Super Contributor
    Join Date
    Oct 2008

    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,

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

    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