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. QButtonBox problem with the button how do I know which one has been clicked
Forum Updated to NodeBB v4.3 + New Features

QButtonBox problem with the button how do I know which one has been clicked

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 259 Views 1 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.
  • A Offline
    A Offline
    AI_Messiah
    wrote on last edited by
    #1

    So I just have the default OK and Cancel

    void Dialog::on_buttonBox_clicked(QAbstractButton *button)
    {
        
        QString myen;
        myen = ui->lineEdit->text();
        entry = myen.toUtf8().constData();
        
    }
    

    I want the entry to be changed with OK and close the dialog with Cancel

    JKSHJ 1 Reply Last reply
    0
    • A AI_Messiah

      So I just have the default OK and Cancel

      void Dialog::on_buttonBox_clicked(QAbstractButton *button)
      {
          
          QString myen;
          myen = ui->lineEdit->text();
          entry = myen.toUtf8().constData();
          
      }
      

      I want the entry to be changed with OK and close the dialog with Cancel

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      @AI_Messiah said in QButtonBox problem with the button how do I know which one has been clicked:

      how do I know which one has been clicked

      Your slot has a QAbstractButton *button parameter that points to the button that was clicked.

      QButtonBox

      There is no class called "QButtonBox". Do you mean QButtonGroup or QDialogButtonBox?

      I want the entry to be changed with OK and close the dialog with Cancel

      If you meant QDialogButtonBox, it emits the accepted() signal when you click "OK", and emits the rejected() signal when you click "Cancel".

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      2

      • Login

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