Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QLocale is not working with Table View

QLocale is not working with Table View

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 900 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CroCo
    wrote on last edited by CroCo
    #1

    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:

    0_1516040473157_Capture.PNG

    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:

    0_1516104528841_Capture.PNG

    0_1516104548802_1.PNG

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Yes, post the code. That will allow people to check what you did and test it also.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      C 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Yes, post the code. That will allow people to check what you did and test it also.

        C Offline
        C Offline
        CroCo
        wrote on last edited by
        #3

        @SGaist please see the update.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved