Unsolved Advice about the application I will be making? (I'm a beginner)
-
@dvlpr.bernard
hi
Well QWidgets does support touch to some degree. Like clicking/pressing,
but not so much slide/swipe and the other normal mobile gestures.
Also scrollbars and the like are default too small to use. (but its fixable)Well if you know javascript besides c++ then QML is pretty smooth.
If you have not worked with javascript and c++ is more your thing, i would
go with QWidgets.That said. If you know web development, have you considered a browser-based solution?
What is your main programming language ?
-
I will consider looking at QML. QWidget was my first choice for now.
My main programming language is C++. I have not done any javascript before. And I probably don't wanna go with browser-based solution because the required language for our project is c++.
-
@dvlpr.bernard
Ok, c++ it is.
The Stacked widget should work fine.
However, regarding the sqllite database. Im not sure its worth digging into
SQL for mere 75 questions.
You could just as easy store it in a text file or for a bit more structure use JSON which
Qt has direct support for. -
@mrjj
Sorry but, can you Elaborate? I don't need SQLite because JSON could do the work for me?
Thank you :) -
@mrjj
Hi. I will try to learn QML. What do you think is the best fit for my app the QT Quick Application - Stack or QT Quick Application - Swipe?
And what are the best resources to learn it out there?Thank you again in advance :)
-
QML seems pretty gorgeous with the user interface. But how am I'm going to work with the back-end kinda stuff??
-
@mrjj
If Javascript is the language for QML then that would be bad because the required languange for the app is c++. -
@dvlpr.bernard
You could write the backend on c++ and expose an object from C++ to QML.
https://doc.qt.io/qt-5/qtqml-cppintegration-contextproperties.html
https://doc.qt.io/qt-5/qtqml-cppintegration-exposecppattributes.html. -
@mrjj Good day sir!
I was just wondering how am I going to present the data? Should I store all the interface in one Stack Widget or do I need another window or another Stack Widget? :)
And also I consider looking at SQLite. Where would I store the questions kinda thing or the output to compare to the user input? Thank you again in advance :)
-
Or it should look like these?
What are the things I need to consider :) -
Hi
Last table looks ok. I assume then all question is a topic and the answer is some
text. No mutiple choice or anything like that ?Since we will have few questions (75) its ok to include the difficult_level
as text. If we were to have thousands of questions, it would be better to have a table for the texts ( Beginner, Average etc) and reference it from Question table.
However, we just directly included it here for simplicity.Next step could be to try use table in Qt
https://doc.qt.io/qt-5/qtsql-index.html
https://katecpp.wordpress.com/2015/08/28/sqlite-with-qt/Things to consider:
Define the operations you need, like
select questions from a diff_level
keeping track of already used questions (if needed ?) -
I was just wondering how am I going to present the data? Should I store all the interface in one Stack Widget or do I need another window or another Stack Widget? :)
I suppose you pretent to use QML. So you can store the data in a model and display components on window depending of your data.
Below is a idea of how you could to implement it with Swipe View (No Interative Mode)
// Qt 5.11 import QtQuick 2.11 import QtQuick.Window 2.11 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.11 Window { visible: true width: 640 height: 480 title: qsTr("Hello World") ListModel{ id: databaseModel ListElement{ topic: "While Loop" dificulty: 3 question_num: 3 question_text: "While Loop 3,3" } ListElement{ topic: "While Loop" dificulty: 3 question_num: 4 question_text: "While Loop 3,4" } } SwipeView { id: view anchors.fill: parent anchors.bottomMargin: 20 interactive: false currentIndex: pageIndicator.currentIndex Repeater { model: databaseModel Loader { active: SwipeView.isCurrentItem || SwipeView.isNextItem || SwipeView.isPreviousItem sourceComponent: Page{ Rectangle{ width: view.width / 2 height: view.height / 2 color: "white" anchors.centerIn: parent Text{ anchors.centerIn: parent text: "Question: " + model.question_text } } } } } } PageIndicator { id: pageIndicator count: databaseModel.count interactive: true currentIndex: 0 anchors.bottom: parent.bottom anchors.horizontalCenter: parent.horizontalCenter } }
Note: the listModel (Data) and Game Logic can be implemented from c++.
And also I consider looking at SQLite. Where would I store the questions kinda thing or the output to compare to the user input? Thank you again in advance :)
Firstly, it may be implement of several ways...
You can insert a Json text with correct_answer index and answers.
Or create an array of text and correct_answer field (i'm not sure how it could be implemented).Json Example:
{ "correct_answer": 0, "answers": [ "Answer 1", "Answer 2", "Answer 3" ] }
Also, the difficulty_level don't need to be a string field. You can storage an intenger number 1-3 and interpret it in your app. 1 -> Beginner, 2 -> Intermediate.
I recommend you to read these materials to understand the Relational Database Concepts:
Telvents - RDBMS Concepts
TutorialsPoint - RDBMS Concepts -
@mrjj
Good day!
Yes, there is no multiple choice included. The user is required to type the output of the set of code that will be displayed.As of now, this is how I visualize the logic or the structure of the app (Please let me know if there are some weaknesses or if this will not gonna work or if there is a better way of doing it):
-
The user will need to choose and click the button(topic name) which has the code that will declare the variable or an object(I don't know what should I use) and will store a data in it.
Example: When the user click the If Statement then int Topic = 1 or string Topic = "IF"; -
When the user click the Beginner button then int Dif_Lvl = 1 or string Dif_Lvl= "Beginner";
-
When the user input the number and click Next button then int Number_Of_Questions = user_input;
Print_Question(Topic, Dif_Lvl, Number_Of_Questions);
The Print_Question function contains the query and a loop to display the next pages depending on the user topic/dif_lvl.
Do I need objects and classes (not that familiar with that) or mostly I would use functions?
Thanks :)
-
-
@KillerSmath
Good day! Thank you for your response.
As of now, I have not learned QML yet. I only know the basic of QT Widget Application and I also tried the Stack Widget in it. QML seems pretty daunting to me for now but I will consider peeking and see if I could work on it.Sadly I need to finish this app within 3 weeks from now or else I would not meet the deadline. I think I wouldn't be able to dig deep into things because that would eat up my time.
-
@dvlpr.bernard said in Advice about the application I will be making? (I'm a beginner):
Do I need objects and classes (not that familiar with that) or mostly I would use functions?
You will be mostly used classes since all Widgets are classes.
the Print_Question should be a member function to the MainWindow so
it can access the widgets. You can use QLabel for the topic (call setText on it)
and QPlainTextEdit for the user / answer input.
The design looks fine. You can realize it with a stacked widget.for both the Topic and Level selection, you have 2 options.
1: as soon as the user click button, its selected and page is changed.
2: You set Checkable on the buttons, so they are like a checkbox ( can be selected) and
first when user press next, the page is changed. -
@mrjj
Good day!Is it possible to store a long string in SQLite database or maybe an image? I need it for the questions or do I?
-
Hi
Storing text in Sqllite should just work. use the TEXT type for the column.Im not sure what you would need any images for ?
-
Okay, did you mean this string? I already tried it but it didn't work I think it is one liner meaning I can't put two or more line data.
I want store an image to make it look more a real code rather than just a plain text, but if it is not possible thats fine.
-
@dvlpr.bernard
where you have string, if u open drop down, there is not TEXT type ?ahh. that way.
well we can fix that later with a syntax highlighter
https://doc.qt.io/qt-5/qtwidgets-richtext-syntaxhighlighter-example.html
so when we set text texts its formatted with colors. no need to store image of it. -
@mrjj
Uhhmm I see, I need to use Text rather than string.
Thank you, thank you!