Help with the basics setting up a Qt Gui
Hi all!
I'm really just getting started with Qt and learning the basics. Historically I've only ever really done Command Line driven stuff, with minimal event drivers.
I wrote a Sudoku Solver in C++ (big whoop I know, but we all started somewhere!). I'd trying to put a Gui together, but I'm really struggling with the basics here. I'd like to set up a 9x9 grid where such that I can display the results of my solver. I thought of using QTableWidget for this, but that was a bit a of a disaster. I thought about doing just a simple matrix of 81 text boxes but can't understand how the gridlayout widget works (is it just me or does a lot of the Qt documentation leave a lot of to be desired - a few examples surely wouldn't kill them). Also - with the 81 text boxes approach, it seems so in-elegant.
Anyway, I thought I'd appeal to the good nature of the coding community and say that I'd really appreciate some handholding.
Thank you in anticipation of your help!
1 Attachment(s)
Re: Help with the basics setting up a Qt Gui
I hope you will find it useful
Code:
#include <QtCore>
#include <QtWidgets>
int main(int argc, char * argv[])
{
mainWidget.setWindowTitle("3x3x3x3");
mainLayout->setSpacing(0);
for(int mr = 0; mr < 3; mr++)
{
for(int mc = 0; mc < 3; mc++)
{
widget
->setFrameStyle
(QFrame::Plain);
widget
->setFrameShape
(QFrame::Box);
gridLayout->setSpacing(0);
gridLayout->setMargin(0);
for(int r = 0; r < 3; r++)
{
for(int c = 0; c < 3; c++)
{
tile
->setFrameStyle
(QFrame::Plain);
tile
->setFrameShape
(QFrame::Box);
tile->setMargin(5);
gridLayout->addWidget(tile, r, c, 1, 1, Qt::AlignCenter);
}
}
mainLayout->addWidget(widget, mr, mc, 1, 1, Qt::AlignCenter);
}
}
mainWidget.show();
return app.exec();
}
#include "main.moc"
Attachment 9414