Skip to content

Commit

Permalink
QcheckOutandRadio Button Project Added
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunny-softdev committed Aug 13, 2020
1 parent 945db55 commit b508a10
Show file tree
Hide file tree
Showing 17 changed files with 2,777 additions and 0 deletions.
31 changes: 31 additions & 0 deletions QCheckBoxDemo/QCheckBoxDemo.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
main.cpp \
widget.cpp

HEADERS += \
widget.h

FORMS += \
widget.ui

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
325 changes: 325 additions & 0 deletions QCheckBoxDemo/QCheckBoxDemo.pro.user

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions QCheckBoxDemo/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "widget.h"

#include <QApplication>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();
return a.exec();
}
106 changes: 106 additions & 0 deletions QCheckBoxDemo/widget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#include "widget.h"
#include "ui_widget.h"
#include <QButtonGroup>
#include <QDebug>

Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);

QButtonGroup *checkBox = new QButtonGroup(this);

checkBox->addButton(ui->WindowscheckBox);
checkBox->addButton(ui->MaccheckBox);
checkBox->addButton(ui->LinuxcheckBox);

checkBox->setExclusive(true);


QButtonGroup *checkBox1 = new QButtonGroup(this);

checkBox1->addButton(ui->juicecheckBox);
checkBox1->addButton(ui->beercheckBox);
checkBox1->addButton(ui->winecheckBox);

checkBox1->setExclusive(false);
}

Widget::~Widget()
{
delete ui;
}


void Widget::on_WindowscheckBox_toggled(bool checked)
{
if(checked)
{
qDebug()<<"Checkbox is checked";
}
else
{
qDebug()<<"Checkbox is unchecked";
}

}

void Widget::on_juicecheckBox_toggled(bool checked)
{
if(checked)
{
qDebug()<<"Juice Checkbox is checked";
}
else
{
qDebug()<<"Juice Checkbox is unchecked";
}
}

void Widget::on_AradioButton_toggled(bool checked)
{
if(checked)
{
qDebug()<<"A Radio button is checked";
}
else
{
qDebug()<<"A Radio button is unchecked";
}
}


void Widget::on_enterData_clicked()
{
if(ui->WindowscheckBox->isChecked() && ui->BradioButton->isChecked()){
qDebug() << "All the required data is selected";
}
else{
qDebug() << "Failed to select the data";
}

}

void Widget::on_setButton_clicked()
{
//Exclusive check
if(ui->WindowscheckBox->isChecked())
{
ui->WindowscheckBox->setChecked(false);
}
else
{
ui->WindowscheckBox->setChecked(true);
}

//Non Exclusive Check
if(ui->winecheckBox->isChecked())
{
ui->winecheckBox->setChecked(false);
}
else
{
ui->winecheckBox->setChecked(true);
}
}
32 changes: 32 additions & 0 deletions QCheckBoxDemo/widget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
Q_OBJECT

public:
Widget(QWidget *parent = nullptr);
~Widget();

private slots:
void on_WindowscheckBox_toggled(bool checked);

void on_juicecheckBox_toggled(bool checked);

void on_AradioButton_toggled(bool checked);

void on_enterData_clicked();

void on_setButton_clicked();

private:
Ui::Widget *ui;
};
#endif // WIDGET_H
129 changes: 129 additions & 0 deletions QCheckBoxDemo/widget.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Widget</class>
<widget class="QWidget" name="Widget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>301</width>
<height>310</height>
</rect>
</property>
<property name="windowTitle">
<string>Widget</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Exclusive Choose OS</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="WindowscheckBox">
<property name="text">
<string>Windows</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="LinuxcheckBox">
<property name="text">
<string>Linux</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="MaccheckBox">
<property name="text">
<string>Mac</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Non-Exclusive Choose Drink</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QCheckBox" name="juicecheckBox">
<property name="text">
<string>Juice</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="beercheckBox">
<property name="text">
<string>Beer</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="winecheckBox">
<property name="text">
<string>Wine</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Choose Answer</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="AradioButton">
<property name="text">
<string>A</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="BradioButton">
<property name="text">
<string>B</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="CradioButton">
<property name="text">
<string>C</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QPushButton" name="enterData">
<property name="text">
<string>Enter</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="setButton">
<property name="text">
<string>Set State</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
QMAKE_CXX.QT_COMPILER_STDCXX = 201402L
QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 8
QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 1
QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 0
QMAKE_CXX.COMPILER_MACROS = \
QT_COMPILER_STDCXX \
QMAKE_GCC_MAJOR_VERSION \
QMAKE_GCC_MINOR_VERSION \
QMAKE_GCC_PATCH_VERSION
QMAKE_CXX.INCDIRS = \
C:/Qt/Tools/mingw810_64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++ \
C:/Qt/Tools/mingw810_64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32 \
C:/Qt/Tools/mingw810_64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward \
C:/Qt/Tools/mingw810_64/lib/gcc/x86_64-w64-mingw32/8.1.0/include \
C:/Qt/Tools/mingw810_64/lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed \
C:/Qt/Tools/mingw810_64/x86_64-w64-mingw32/include
QMAKE_CXX.LIBDIRS = \
C:/Qt/Tools/mingw810_64/lib/gcc/x86_64-w64-mingw32/8.1.0 \
C:/Qt/Tools/mingw810_64/lib/gcc \
C:/Qt/Tools/mingw810_64/x86_64-w64-mingw32/lib \
C:/Qt/Tools/mingw810_64/lib
Loading

0 comments on commit b508a10

Please sign in to comment.