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. [SOLVED] callback

[SOLVED] callback

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 1.9k Views
  • 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.
  • L Offline
    L Offline
    leo4as
    wrote on 16 Jun 2014, 12:37 last edited by
    #1

    i will try to make it very simple
    i have 2 classes:

    class_1.h
    calss_1.cpp
    class_1.ui

    this is the class_1.ui

    !http://s30.postimg.org/4gx1zh1ip/designe.png(class_1.ui)!

    the tab element is promoted to second class "tab_content"

    tab_content.h
    tab_content.cpp
    tab_content.ui

    the tab_content.ui have a QPushButton named title_pb

    when the button clicked the tab in class_1 must change to ui->title_pb->text() in the tab_content

    how to do that ?

    leo4as

    1 Reply Last reply
    0
    • X Offline
      X Offline
      xcoder
      wrote on 16 Jun 2014, 12:59 last edited by
      #2

      Not sure what you mean, but...

      One approach would be to create custom signal in your tab_content class, and emit it when a button is pressed.

      In your class_1 you can just connect to the custom signal and forward it to a method for changing the title.

      Check "signals & slots":http://qt-project.org/doc/qt-5/signalsandslots.html in Qt documentation.

      Only a biker knows why a dog sticks his head out of a car window.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        arsinte_andrei
        wrote on 16 Jun 2014, 13:22 last edited by
        #3

        as already advised using signal and slots and as far as I can see because you are using creator and designer, than you can right click on the button and then <go to Slot> followed by <clicked()> and there you can create your code to @ui->title_pb->setText("<what ever you whant here>") @

        1 Reply Last reply
        0
        • L Offline
          L Offline
          leo4as
          wrote on 16 Jun 2014, 13:47 last edited by
          #4

          thank you i get it :
          in the tab_content.h :
          @
          private slots:
          void on_pushButton_clicked();

          signals:
          void change_title(QString title);
          @

          tab_content.cpp :
          @
          void tab_content::on_pushButton_clicked()
          {
          emit change_title(ui->pushButton->text());
          }
          @

          class_1.h :
          @
          private slots:
          void change_tab_name(QString title);
          @

          class_1.cpp :
          @
          void class_1::change_tab_name(QString title)
          {
          ui->tabWidget->setTabText(ui->tabWidget->currentIndex(), title);
          }
          @

          and the contructor :
          @
          connect(ui->tab, SIGNAL(change_title(QString)), this, SLOT(change_tab_name(QString)));
          @

          leo4as

          1 Reply Last reply
          0
          • X Offline
            X Offline
            xcoder
            wrote on 16 Jun 2014, 13:48 last edited by
            #5

            Exactly. Don't forget to mark this thread Solved

            Only a biker knows why a dog sticks his head out of a car window.

            1 Reply Last reply
            0
            • L Offline
              L Offline
              leo4as
              wrote on 16 Jun 2014, 14:06 last edited by
              #6

              how to do that :p

              leo4as

              1 Reply Last reply
              0
              • X Offline
                X Offline
                xcoder
                wrote on 16 Jun 2014, 14:07 last edited by
                #7

                Just edit your original post, and in the front of your title add "[SOLVED]"

                Only a biker knows why a dog sticks his head out of a car window.

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  leo4as
                  wrote on 16 Jun 2014, 14:08 last edited by
                  #8

                  ok tnx :)

                  leo4as

                  1 Reply Last reply
                  0

                  1/8

                  16 Jun 2014, 12:37

                  • Login

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