Results 1 to 15 of 15

Thread: QCheckBox example?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: QCheckBox example?

    You already have the code. Connect the signal from whatever widget the user uses to actually attempt to start the program to a slot containing the code from your first post. You do not need to connect the checkbox to anything unless you want the program to launch every time the checkbox is clicked.

    Qt Code:
    1. // slot
    2. void goForthAndExecute()
    3. {
    4. // QProcess commandProcess;
    5.  
    6. if (ui->check2pass->isChecked()){
    7. args << "-pass"; args << "2";
    8. }
    9. commandProcess.start("C:/ffmpeg.exe",args);
    10. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by ChrisW67; 9th December 2010 at 06:17.

  2. #2
    Join Date
    Sep 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QCheckBox example?

    I have QProcess commandProcess; in my header file already. I have something like
    [CODE]
    void Encode ()
    {

    QStringList args;

    args << "-i";
    args << "-ac"; args << ui->comboResolution->currentText();


    if (ui->check2pass->isChecked()){

    args << "-pass"; args << "2";

    }

    commandProcess.start("C:/ffmpeg.exe",args);

    }
    [CODE]

    I believe it didn't work though the checkbox args weren't recognized. What do you think I am missing?
    Last edited by Milardo; 9th December 2010 at 05:56.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: QCheckBox example?

    What triggers a call to Encode()?

  4. #4
    Join Date
    Sep 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QCheckBox example?

    that would be a pushbutton in the gui, basically i check the box, and i want to when i push the Encode button that checkbox args to be applied.

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: QCheckBox example?

    Have you connected the clicked() signal of the push button to this slot?

  6. #6
    Join Date
    Sep 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QCheckBox example?

    yes i have

  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: QCheckBox example?

    Well then, you need to put a breakpoint in the slot and single step through it checking that it follows the path you are expecting and that everything has the values you are expecting.

  8. #8
    Join Date
    Sep 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QCheckBox example?

    yeah i will check it again but everything worked correctly except my "if" statements regarding checkbox

  9. #9
    Join Date
    Dec 2010
    Posts
    13
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: QCheckBox example?

    So if you write
    Qt Code:
    1. if (ui->check2pass->isChecked()){
    2. args << "-pass"; args << "2";
    3. } else {
    4. qDebug("Failed Event.");
    5. }
    To copy to clipboard, switch view to plain text mode 

    It will print out Failed Event?

  10. #10
    Join Date
    Sep 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QCheckBox example?

    sorry i can't verify that as i'm on a different computer now but i will try that any other suggestions would be welcome.

Similar Threads

  1. About QCheckBox
    By liushuo0826 in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 16th April 2010, 07:14
  2. QCheckBox in QTreeWidget
    By Kode.Cooper in forum Qt Programming
    Replies: 3
    Last Post: 25th March 2010, 06:55
  3. QCheckBox value
    By Koas in forum Qt Programming
    Replies: 2
    Last Post: 19th January 2009, 14:33
  4. Read-only QCheckBox
    By alu23 in forum Qt Programming
    Replies: 2
    Last Post: 22nd April 2008, 17:25
  5. QCheckbox
    By sonuani in forum Qt Programming
    Replies: 1
    Last Post: 19th February 2008, 14:12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.