QLocale is not working with Table View
Unsolved
General and Desktop
-
I'm hitting a walk with QTableView. I've tried to subclass its QHeaderView with no luck. I've came a cross a feature which is setting QLocale but failed. QLocale works with QDate Widget but failed with QTableView for numbering the vertical header view see the following picture:
Why it failed with QTableView? This is simple code. I don't feel I need to paste it but I will if you insist. Thank you.
Update:
The code is
dailog.cpp
#include "dialog.h" #include "ui_dialog.h" #include <QVBoxLayout> Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog) { ui->setupUi(this); m_model = new QStandardItemModel(50,5,this); m_model->setHorizontalHeaderItem(0, new QStandardItem(QString("الرمز"))); m_model->setHorizontalHeaderItem(1, new QStandardItem(QString("الصنف"))); m_model->setHorizontalHeaderItem(2, new QStandardItem(QString("الكمية"))); m_model->setHorizontalHeaderItem(3, new QStandardItem(QString("السعر"))); m_model->setHorizontalHeaderItem(4, new QStandardItem(QString("الإجمالـي"))); ui->tableview->setModel(m_model); ui->tableview->setLayoutDirection(Qt::RightToLeft); ui->tableview->verticalHeader()->setDefaultAlignment(Qt::AlignCenter); ui->tableview->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); //ui->tableview->setHorizontalHeader(m_headerview); //QLocale arab(QLocale::Arabic, QLocale::SaudiArabia); //ui->tableview->setLocale(arab); //ui->tableview->verticalHeader()->setLocale(arab); } Dialog::~Dialog() { delete ui; }
dailog.h
#ifndef DIALOG_H #define DIALOG_H #include <QDialog> #include <QStandardItemModel> namespace Ui { class Dialog; } class Dialog : public QDialog { Q_OBJECT public: explicit Dialog(QWidget *parent = 0); ~Dialog(); private: Ui::Dialog *ui; QStandardItemModel *m_model; }; #endif // DIALOG_H
main.cpp
#include "dialog.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); Dialog w; w.show(); return a.exec(); }
In the form:
-
Hi,
Yes, post the code. That will allow people to check what you did and test it also.