Update Windows Title in Embedded Application



  • Hi All,
    I have developed a simple ticket booking application, set the windows title using "setWindowTitle" method and its working fine. Now I have two methods connected to two push buttons "New Booking" and "Cancel Booking"
    Now I want, when someone press "New Booking" button, the main window title should be updated to "New Booking" and for "Cancel Booking" the same accordingly.
    I tried to use "setWindowTitle" inside "newBooking" method it it is giving me segmentation fault.
    Hope to get help accordingly.

    Thanks



  • @Kashif Hello,

    Do you have any code?
    I created a quick test app that calls setWindowTitle() in a slot when a QPushButton is clicked in Qt Creator, everything works fine

    Not clicked:
    alt text
    Title changes when button is clicked:
    alt text



  • Hi @applqpak,

    Sorry I missed to mention that I am working on embedded device with Linux kernel, using QTopia+widget application.

    Following is code snippet for your reference:

    //main.cpp
    
    #include "gprs_connect.h"
    #include <qtopiaapplication.h>
    
    QTOPIA_ADD_APPLICATION(QTOPIA_TARGET, GPRSConnect)
    QTOPIA_MAIN
    
    
    //gprsConnect.cpp
    GPRSConnect::GPRSConnect(QWidget *parent, Qt::WindowFlags f)
            : QMainWindow(parent, f)
    {
    
        setWindowTitle("Easy Ticket");   //This works fine
    
        centralWidget = new QWidget(this);
        layout = new QVBoxLayout(centralWidget);
        QString label_state;
    
        label_state="Select Your Option";
    
        lblTranName = new QLabel("IDLE MENU", centralWidget);
        layout->addWidget(lblTranName);
    
        lblTranMsgs = new QLabel(label_state, centralWidget);
        layout->addWidget(lblTranMsgs);
    
        layout->addStretch();
    
        purButton = new QPushButton(tr("Purchase"), centralWidget);
        connect(purButton, SIGNAL(clicked(bool)), SLOT(Purchase()));
        layout->addWidget(purButton);
    
        refundButton = new QPushButton(tr("Refund"), centralWidget);
        connect(refundButton, SIGNAL(clicked(bool)), SLOT(refund()));
        layout->addWidget(refundButton);
    
        quitButton = new QPushButton(tr("Quit"), centralWidget);
        connect(quitButton, SIGNAL(clicked(bool)), SLOT(close()));
        layout->addWidget(quitButton);
    
        layout->setMargin(0);
        layout->setSpacing(0);
        setCentralWidget(centralWidget); 
    
    }
    
    
    void GPRSConnect::Purchase()
    {
        QFont fontDef = lblTranMsgs->font();
        QFont fontNew = lblTranMsgs->font();
        fontNew.setBold(true);
        lblTranMsgs->setFont(fontNew);
        lblTranMsgs->update();
        lblTranMsgs->repaint();
    	
        //setWindowTitle("PURCHASE");   //Segmentation Fault
        QWidget::setWindowTitle("PURCHASE");   //Segmentation Fault
    
    }
    

  • Lifetime Qt Champion

    Hi,

    Qtopia ? Are you locked to it ? That's a project that has reached EOL 8 years ago so it's not necessarily a good idea to start a new project with it.



  • Hi @SGaist,
    Its a new device for me, and I am following the base code provided by the device vendor. I don't know how to change the architecture and if i do something how to make it work on device.
    I tried hello world ui application, compiled successfully but it gives me run time exceptions on device.

    Hope this answers your query.

    Thanks


  • Lifetime Qt Champion

    You should check with the vendor if you can use something a bit more recent.

    As for your error, can you get a stack trace ?



  • Hi @SGaist,

    Sorry for delayed response as I am woking in Qatar and we have weekend for Friday/Saturday.
    I tried again the same thing and I am not getting exception now, no idea what I had done before, may be some uninitialized pointer that I may have fixed when moving forward to application logical code.
    Currently as I mentioned that I am not getting exception but issue is that the main window title is getting updated when the control is returned back to main constructor. Also to mention that I have disabled the push buttons in the same function and that code is working fine:
    For the main window title I have placed following line of code:

        setWindowTitle("PURCHASE");
        centralWidget->update();
        centralWidget->repaint();
    
    

    Thanks


  • Lifetime Qt Champion

    The QMainWindow title has nothing to do with the central widget.



  • Hi @SGaist,
    Can you please write me a line or reference on how do to update QMainWindow title in my code as I am not using "ui" component so its something unknown for me.

    Thanks


  • Lifetime Qt Champion

    Well:
    @Kashif said in Update Windows Title in Embedded Application:

    setWindowTitle

    of your QMainWindow is the right method AFAIR.

    Can you show what you get ?



  • Hi @SGaist,

    I used this function in my code but the title is getting updated only when the control returns back to push button calling event (the class constructor where I have defined central widget and buttons, code is pasted in third comment)

    Thanks


  • Lifetime Qt Champion

    Why are you calling QWidget::setWindowTitle rather than just setWindowTitle ?



  • Hi @SGaist,

    I tried both and the outcome is same.

    Thanks


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.