Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. The QLabel text not change.
Forum Updated to NodeBB v4.3 + New Features

The QLabel text not change.

Scheduled Pinned Locked Moved General and Desktop
qlabel
8 Posts 2 Posters 3.2k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • MhM93M Offline
    MhM93M Offline
    MhM93
    wrote on last edited by
    #1

    Hi. I have a program that change the label text when that form is active. but it shows me SIGSEV error.
    the mainwindow that send string to active window:

    UserManage *mf;
        QWidget *f=QApplication::activeWindow();
        //if(mf!=NULL)
        if(f->windowTitle()=="User-Management")
        {
            //QMessageBox::warning(this, tr("Login failed"), "UserMng", QMessageBox::Ok);
            mf->processData(output);
            return;
        }
    

    the second form that show the string :

    //============================
    void UserManage::processData(QString output)
    {
        ui->lblRFIDdata->setText(output);
    }
    
    

    the Qlabel.cpp error:

    void QLabel::setText(const QString &text)
    {
        Q_D(QLabel);-------> this line
        if (d->text == text)
            return;
    

    error details :

    0	QLabel::setText	qlabel.cpp	337	0xb7aa286a	 -------> this line
    1	UserManage::processData	usermanage.cpp	53	0x806ff60	
    2	MainWindow::ReadAndProcessData	mainwindow.cpp	162	0x804ed3f	
    3	MainWindow::qt_metacall	moc_mainwindow.cpp	83	0x8074800	
    4	QMetaObject::metacall	qmetaobject.cpp	237	0xb73e1fa5	
    5	QMetaObject::activate	qobject.cpp	3287	0xb73eeaf6	
    6	QSocketNotifier::activated	moc_qsocketnotifier.cpp	89	0xb7436a15	
    7	QSocketNotifier::event	qsocketnotifier.cpp	317	0xb73f538f	
    8	QApplicationPrivate::notify_helper	qapplication.cpp	4302	0xb76494d4	
    9	QApplication::notify	qapplication.cpp	4110	0xb764fabb	
    10	QCoreApplication::notifyInternal	qcoreapplication.cpp	726	0xb73dc56a	
    11	sendEvent	qcoreapplication.h	215	0xb74065f7	
    12	QEventDispatcherUNIX::activateSocketNotifiers	qeventdispatcher_unix.cpp	878	0xb74065f7	
    13	QEventDispatcherUNIXPrivate::doSelect	qeventdispatcher_unix.cpp	304	0xb7406938	
    14	QEventDispatcherUNIX::processEvents	qeventdispatcher_unix.cpp	920	0xb7406d33	
    15	QEventDispatcherX11::processEvents	qeventdispatcher_x11.cpp	152	0xb76eaddd	
    16	QEventLoop::processEvents	qeventloop.cpp	149	0xb73db843	
    17	QEventLoop::exec	qeventloop.cpp	201	0xb73dbad1	
    18	QCoreApplication::exec	qcoreapplication.cpp	1003	0xb73e01fe	
    19	QApplication::exec	qapplication.cpp	3581	0xb76481c4	
    20	main	main.cpp	15	0x804de4d	
    ...	<More>		
    
    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      I looks like you are using a non initialized pointer.

      UserManage *mf; // points to nothing. dangling pointer
      ...
      mf->processData(output); // this will crash if mf never points to valid object.

      MhM93M 1 Reply Last reply
      3
      • mrjjM mrjj

        Hi
        I looks like you are using a non initialized pointer.

        UserManage *mf; // points to nothing. dangling pointer
        ...
        mf->processData(output); // this will crash if mf never points to valid object.

        MhM93M Offline
        MhM93M Offline
        MhM93
        wrote on last edited by MhM93
        #3

        @mrjj : thanks
        I change that to

        UserManage *mf=new UserManage;
            QWidget *f=QApplication::activeWindow();
            //if(mf!=NULL)
            if(f->windowTitle()=="User-Management")
            {
                //QMessageBox::warning(this, tr("Login failed"), "UserMng", QMessageBox::Ok);
                mf->processData(output);
                return;
            }
        

        I want to change the label in my form number 3 from form number 1 with . It works on tracing code with breakpoints. when receive to this method is worked

        void UserManage::processData(QString output)
        {
            ui->lblRFIDdata->setText(output);
        }
        

        but when finished the method it goes to QWidget.cpp class and show error here :

        QString QWidget::windowTitle() const
        {
            Q_D(const QWidget);
            if (d->extra && d->extra->topextra) {
        
        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Maybe "f" is NULL ?

          MhM93M 1 Reply Last reply
          0
          • mrjjM mrjj

            Maybe "f" is NULL ?

            MhM93M Offline
            MhM93M Offline
            MhM93
            wrote on last edited by
            #5

            @mrjj : sorry. I had a mistake. It solved. there is no error.
            BUT the label does not change
            why ? !!!!
            (f is get the active form name)

            mrjjM 1 Reply Last reply
            0
            • MhM93M MhM93

              @mrjj : sorry. I had a mistake. It solved. there is no error.
              BUT the label does not change
              why ? !!!!
              (f is get the active form name)

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @MhM93 said:

              UserManage

              Is that the class where you expect the label to change?
              Since you are not showing the new one you create,
              you might be looking at another UserManage
              than the one you make here
              UserManage *mf=new UserManage; << new one
              // u dont have
              mf->show();
              so might not see it at all ?
              It wont change label for any other UserManage you might have in project.
              only for "mf"

              MhM93M 1 Reply Last reply
              0
              • mrjjM mrjj

                @MhM93 said:

                UserManage

                Is that the class where you expect the label to change?
                Since you are not showing the new one you create,
                you might be looking at another UserManage
                than the one you make here
                UserManage *mf=new UserManage; << new one
                // u dont have
                mf->show();
                so might not see it at all ?
                It wont change label for any other UserManage you might have in project.
                only for "mf"

                MhM93M Offline
                MhM93M Offline
                MhM93
                wrote on last edited by
                #7
                This post is deleted!
                1 Reply Last reply
                0
                • MhM93M Offline
                  MhM93M Offline
                  MhM93
                  wrote on last edited by
                  #8

                  I changed it to this code:

                  QWidget *f=QApplication::activeWindow();
                     //if(mf!=NULL)
                     if(f->windowTitle()=="User-Management")
                     {
                         //QMessageBox::warning(this, tr("Login failed"), "UserMng", QMessageBox::Ok);
                         QLabel* lbl = f->findChild<QLabel*>("lblRFIDdata");
                         //mf->processData(output);
                         lbl->setText(output);
                         return;
                     }
                  

                  and the label change. really thanks.

                  1 Reply Last reply
                  1

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved