Hi,
How can I implement a timetable like widget on Qt as shown in the image below?
http://www.microsoft.com/library/med...ime_limits.jpg
This widget allows me to select / deselect the time slot.
Thanks in advance.
Printable View
Hi,
How can I implement a timetable like widget on Qt as shown in the image below?
http://www.microsoft.com/library/med...ime_limits.jpg
This widget allows me to select / deselect the time slot.
Thanks in advance.
Use a simple QTableView/QTableWidget.
Thanks for pointing out the relevant Qt classes, Lykurg. Which class is better to be use in my case, QTableView or QTableWidget? Would like to use the simple approach in getting this done.
From the documentations, QTableWidget inherits QTableView.
So, how would I know if a user clicks on a cell (or click-drag multiple horizontal cells for longer time slots) to make the selection or deselection?
Then, I would have to alternate (or switch between a range of colors for different options, e.g. busy, tentative, and free) the colors of the cells when I receive these events.
Thanks in advance.
Anyone knows how to multi select cells without pressing Ctrl?
Try playing with QAbstractItemView::SelectionMode and see which mode meets your needs.
I always suggest to use the Q*View instead of the Q*Widget-classes. The difference is that the *Widget come with their own model, for the *View, you have to write the model yourself.
BUT: In the end, the model provides your business logic. If you use the standard model that is provided by Qt, you will not be able to use most of the features of their model-view framework.
Let's say my model subclassed from QAbstractTableModel.
I'm implementing my data structure as QList<QList<bool>>.
I'm using the normal QTableView, not a custom widget.
How do I usethe onClick event of a cell to change the bool value in that particular cell?
Thanks in advance.
You can use QAbstractItemView::clicked(const QModelIndex &) signal to connect to your custom slot.
Single selection of QModelIndex is alright for me now. However, I'm wondering how can I use QAbstractItemView::selectedIndexes () const [virtual protected] to get the list of multiple selected cells' QModelIndexes? Should I should use QAbstractItemDelegate?
E.g. multiple selection cells using Ctrl - Left mouse click / Shift / Left mouse click and drag to select cells?
You can access selected indexes through QAbstractItemView::selectionModel().
Code:
tableView->selectionModel()->selectedIndexes();
Maybe, yes.... I don't understand with "after some event from MainWindow".
For example, if you have a pushbutton, you connect it's clicked() signal to your pusbutton_clicked() slot, then in your pushbutton_clicked() function you called selectedIndexes().
I did tried to use the code below to make left-click drag and multiple selection of cells. It works with multiple selection. However, I cannot make entered() and clicked() mutually exclusive to each other for a cell. It triggers double events called when clicked and the reverted the value. Any other approaches?
Also, how can I paint a "focus" rectangle upon mouse hover a QTableView's cell?Code:
connect( tableView, SIGNAL(entered(const QModelIndex &) ), this, SLOT( setOnOff(const QModelIndex &) ) ); connect( tableView, SIGNAL(clicked(const QModelIndex &) ), this, SLOT( setOnOff(const QModelIndex &) ) );