Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sudoku solver
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Silas Dohm
sudoku solver
Commits
dee1cc35
Commit
dee1cc35
authored
3 years ago
by
Silas Dohm
Browse files
Options
Downloads
Patches
Plain Diff
basic func
parent
35127515
No related branches found
No related tags found
1 merge request
!1
Master
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
CMakeLists.txt
+2
-0
2 additions, 0 deletions
CMakeLists.txt
Makefile
+27
-0
27 additions, 0 deletions
Makefile
cell.cpp
+36
-8
36 additions, 8 deletions
cell.cpp
cell.h
+13
-4
13 additions, 4 deletions
cell.h
window.cpp
+36
-38
36 additions, 38 deletions
window.cpp
window.h
+3
-1
3 additions, 1 deletion
window.h
with
117 additions
and
51 deletions
CMakeLists.txt
+
2
−
0
View file @
dee1cc35
...
...
@@ -18,6 +18,8 @@ set(PROJECT_SOURCES
main.cpp
window.h
window.cpp
cell.h
cell.cpp
)
if
(
${
QT_VERSION_MAJOR
}
GREATER_EQUAL 6
)
...
...
This diff is collapsed.
Click to expand it.
Makefile
+
27
−
0
View file @
dee1cc35
...
...
@@ -142,6 +142,30 @@ sodoku_solver_autogen/fast:
$(
MAKE
)
$(
MAKESILENT
)
-f
CMakeFiles/sodoku_solver_autogen.dir/build.make CMakeFiles/sodoku_solver_autogen.dir/build
.PHONY
:
sodoku_solver_autogen/fast
cell.o
:
cell.cpp.o
.PHONY
:
cell.o
# target to build an object file
cell.cpp.o
:
$(
MAKE
)
$(
MAKESILENT
)
-f
CMakeFiles/sodoku_solver.dir/build.make CMakeFiles/sodoku_solver.dir/cell.cpp.o
.PHONY
:
cell.cpp.o
cell.i
:
cell.cpp.i
.PHONY
:
cell.i
# target to preprocess a source file
cell.cpp.i
:
$(
MAKE
)
$(
MAKESILENT
)
-f
CMakeFiles/sodoku_solver.dir/build.make CMakeFiles/sodoku_solver.dir/cell.cpp.i
.PHONY
:
cell.cpp.i
cell.s
:
cell.cpp.s
.PHONY
:
cell.s
# target to generate assembly for a file
cell.cpp.s
:
$(
MAKE
)
$(
MAKESILENT
)
-f
CMakeFiles/sodoku_solver.dir/build.make CMakeFiles/sodoku_solver.dir/cell.cpp.s
.PHONY
:
cell.cpp.s
main.o
:
main.cpp.o
.PHONY
:
main.o
...
...
@@ -224,6 +248,9 @@ help:
@
echo
"... rebuild_cache"
@
echo
"... sodoku_solver_autogen"
@
echo
"... sodoku_solver"
@
echo
"... cell.o"
@
echo
"... cell.i"
@
echo
"... cell.s"
@
echo
"... main.o"
@
echo
"... main.i"
@
echo
"... main.s"
...
...
This diff is collapsed.
Click to expand it.
cell.cpp
+
36
−
8
View file @
dee1cc35
#include
"cell.h"
#include
<QPushButton>
#include
<QDebug>
#include
<QSignalMapper>
Cell
::
Cell
(
QWidget
*
parent
)
:
QWidget
(
parent
)
Cell
::
Cell
(
QWidget
*
parent
)
:
QWidget
(
parent
)
{
// Set size of the window
setFixedSize
(
100
,
50
);
// Create and position the button
m_button
=
new
QPushButton
(
"Hello World"
,
this
);
m_button
->
setGeometry
(
10
,
10
,
80
,
30
);
setAutoFillBackground
(
true
);
setStyleSheet
(
"background-color:gray;"
);
setFixedSize
(
100
,
100
);
// qInfo("width=%d,height=%d",parent->width(),height());
float
w
=
width
()
/
3.0
;
float
h
=
height
()
/
3.0
;
QSignalMapper
*
mapper
=
new
QSignalMapper
(
this
);
connect
(
mapper
,
SIGNAL
(
mapped
(
int
)),
this
,
SLOT
(
slotButtonClicked
(
int
)));
for
(
char
i
=
0
;
i
<
9
;
i
++
)
{
states
[
i
]
=
new
QPushButton
(
QString
::
number
(
i
),
this
);
states
[
i
]
->
setGeometry
(
i
%
3
*
w
,
i
/
3
*
h
,
w
,
h
);
states
[
i
]
->
setStyleSheet
(
"border:none"
);
connect
(
states
[
i
],
SIGNAL
(
clicked
()),
mapper
,
SLOT
(
map
()));
mapper
->
setMapping
(
states
[
i
],
i
);
}
collapsed
=
new
QPushButton
(
this
);
collapsed
->
setFixedSize
(
100
,
100
);
collapsed
->
setStyleSheet
(
"font-size:44px"
);
collapsed
->
hide
();
}
void
Cell
::
slotButtonClicked
(
int
x
)
{
collapsed
->
show
();
collapsed
->
setText
(
QString
::
number
(
x
));
emit
(
collapse
(
x
));
}
void
Cell
::
foo
(
int
x
)
{
states
[
x
]
->
hide
();
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
cell.h
+
13
−
4
View file @
dee1cc35
...
...
@@ -6,10 +6,19 @@
class
QPushButton
;
class
Cell
:
public
QWidget
{
Q_OBJECT
public:
explicit
Cell
(
QWidget
*
parent
=
0
);
private:
QPushButton
*
m_button
;
QPushButton
*
states
[
9
];
QPushButton
*
collapsed
;
signals:
void
collapse
(
int
x
);
public
slots
:
void
foo
(
int
x
);
private
slots
:
void
slotButtonClicked
(
int
x
);
};
#endif // CELL_H
\ No newline at end of file
This diff is collapsed.
Click to expand it.
window.cpp
+
36
−
38
View file @
dee1cc35
#include
"window.h"
#include
<QApplication>
#include
<QStandardPaths>
#include
<QDebug>
Window
::
Window
(
QWidget
*
parent
)
:
QWidget
{
parent
}
{
setFixedSize
(
1600
,
900
);
m_counter
=
0
;
// quitbutton
// m_buttonQuit = new QPushButton("quit", this);
// m_buttonQuit->setGeometry(0, height() - 30, width(), 30);
for
(
char
x
=
0
;
x
<
9
;
x
++
)
int
dx
=
0
;
int
dy
=
0
;
for
(
int
x
=
0
;
x
<
9
;
x
++
)
{
for
(
char
y
=
0
;
y
<
1
;
y
++
)
for
(
int
y
=
0
;
y
<
9
;
y
++
)
{
grid
[
x
][
y
]
=
new
QPushButton
(
"x"
,
this
);
grid
[
x
][
y
]
->
setGeometry
(
x
*
100
,
y
*
100
,
100
,
100
);
if
(
x
==
3
)
dx
=
4
;
if
(
x
==
6
)
dx
=
8
;
if
(
y
<
3
)
dy
=
0
;
if
(
y
>=
3
)
dy
=
4
;
if
(
y
>=
6
)
dy
=
8
;
m_cell
[
x
][
y
]
=
new
Cell
(
this
);
m_cell
[
x
][
y
]
->
setGeometry
(
x
*
100
+
dx
,
y
*
100
+
dy
,
100
,
100
);
/* code */
}
}
// slider
// m_slider = new QSlider(this);
// m_slider->setOrientation(Qt::Horizontal);
// m_slider->setRange(0, 100);
// m_slider->setValue(0);
// m_slider->setGeometry(10, 20, width() - 10, 20);
// // progressbar
// m_progressBar = new QProgressBar(this);
// m_progressBar->setRange(0, 100);
// m_progressBar->setValue(0);
// m_progressBar->setGeometry(10, 40, width() - 10, 20);
// // button
// m_button = new QPushButton("Hello QT!", this);
// m_button->setGeometry(0, 80, width(), 30);
// m_button->setCheckable(true);
// // signals and slots :)
// connect(m_button, SIGNAL(clicked(bool)), this, SLOT(slotButtonClicked(bool)));
// connect(m_buttonQuit, SIGNAL(clicked()), QApplication::instance(), SLOT(quit()));
// connect(m_slider, SIGNAL(valueChanged(int)), m_progressBar, SLOT(setValue(int)));
// connect(this, SIGNAL(counterReached()), QApplication::instance(), SLOT(quit()));
// init signals
for
(
int
x
=
0
;
x
<
9
;
x
++
)
{
for
(
int
y
=
0
;
y
<
9
;
y
++
)
{
for
(
int
d
=
0
;
d
<
9
;
d
++
)
{
connect
(
m_cell
[
x
][
y
],
SIGNAL
(
collapse
(
int
)),
m_cell
[
x
][
d
],
SLOT
(
foo
(
int
)));
connect
(
m_cell
[
x
][
y
],
SIGNAL
(
collapse
(
int
)),
m_cell
[
d
][
y
],
SLOT
(
foo
(
int
)));
}
void
Window
::
slotButtonClicked
(
bool
checked
)
int
a
=
x
/
3
*
3
;
int
b
=
y
/
3
*
3
;
for
(
int
x1
=
a
;
x1
<
a
+
3
;
x1
++
)
{
checked
?
m_button
->
setText
(
"Checked"
)
:
m_button
->
setText
(
"Hello QT!"
);
m_counter
++
;
if
(
m_counter
==
10
)
for
(
int
y1
=
b
;
y1
<
b
+
3
;
y1
++
)
{
emit
counterReached
();
connect
(
m_cell
[
x
][
y
],
SIGNAL
(
collapse
(
int
)),
m_cell
[
x1
][
y1
],
SLOT
(
foo
(
int
)));
}
}
}
}
}
This diff is collapsed.
Click to expand it.
window.h
+
3
−
1
View file @
dee1cc35
...
...
@@ -5,6 +5,7 @@
#include
<QPushButton>
#include
<QProgressBar>
#include
<QSlider>
#include
"cell.h"
class
Window
:
public
QWidget
{
Q_OBJECT
...
...
@@ -16,11 +17,12 @@ private:
QPushButton
*
grid
[
9
][
9
];
QProgressBar
*
m_progressBar
;
QSlider
*
m_slider
;
Cell
*
m_cell
[
9
][
9
];
int
m_counter
;
signals:
void
counterReached
();
private
slots
:
void
slotButtonClicked
(
bool
checked
);
};
#endif // WINDOW_H
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment