DateTimeEdit in QML like in QtwidgetsQt QML dropdown list like in HTMLHow to control QML UI with PySide?Include another QML file from a QML fileis it possible to bind javascript and qtwidgets?Qt QML component like WPF HwndHostHow to apply regexp to TextEdit like in Qt Widgets?QML Camera size issueQt QML : GrabToImage functionality possible with QMLTemplateIs it not possible to create a map datatype in QML?Using QML with a qt widgets type of ui form?

Do predators tend to have vertical slit pupils versus horizontal for prey animals?

Output with the same length always

Are there any OR challenges that are similar to kaggle's competitions?

What does a comma signify in inorganic chemistry?

Short Story: Cold War setting. In orbit, two astronauts decide whether to launch nuclear counter strike ("MAD" scenario). Twist at end

Photoshop older default brushes

Why do we use low resistance cables to minimize power losses?

Has there ever been a truly bilingual country prior to the contemporary period?

Have made several mistakes during the course of my PhD. Can't help but feel resentment. Can I get some advice about how to move forward?

Meaning and structure of headline "Hair it is: A List of ..."

Is Fourier series a sampled version of Fourier transform?

What should we do with manuals from the 80s?

Is the Microsoft recommendation to use C# properties applicable to game development?

Combinatorial Argument for Exponential and Logarithmic Function Being Inverse

How to train a replacement without them knowing?

Why is the battery jumpered to a resistor in this schematic?

What's a good pattern to calculate a variable only when it is used the first time?

Parse a simple key=value config file in C

Airline power sockets shut down when I plug my computer in. How can I avoid that?

What allows us to use imaginary numbers?

What is the purpose/function of this power inductor in parallel?

μονάδαι as plural form of μονάς

A+ rating still unsecure by Google Chrome's opinion

Why do so many people play out of turn on the last lead?



DateTimeEdit in QML like in Qtwidgets


Qt QML dropdown list like in HTMLHow to control QML UI with PySide?Include another QML file from a QML fileis it possible to bind javascript and qtwidgets?Qt QML component like WPF HwndHostHow to apply regexp to TextEdit like in Qt Widgets?QML Camera size issueQt QML : GrabToImage functionality possible with QMLTemplateIs it not possible to create a map datatype in QML?Using QML with a qt widgets type of ui form?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















In QtWidgets we have something called QDateTimeEdit like below image



enter image description here



do we have any thing similar in QML that does this? I searched online and could not find any.










share|improve this question
































    0















    In QtWidgets we have something called QDateTimeEdit like below image



    enter image description here



    do we have any thing similar in QML that does this? I searched online and could not find any.










    share|improve this question




























      0












      0








      0








      In QtWidgets we have something called QDateTimeEdit like below image



      enter image description here



      do we have any thing similar in QML that does this? I searched online and could not find any.










      share|improve this question
















      In QtWidgets we have something called QDateTimeEdit like below image



      enter image description here



      do we have any thing similar in QML that does this? I searched online and could not find any.







      qt qml






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 27 at 19:29









      eyllanesc

      106k12 gold badges38 silver badges70 bronze badges




      106k12 gold badges38 silver badges70 bronze badges










      asked Mar 27 at 12:56









      TechiesoftTechiesoft

      899 bronze badges




      899 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          1














          There is no equivalent in QML. But, you can easily create your own widget with a TextField and a custom validator:



          In QML:



          TextField 
          text : "01/01/1970 00:00:00"
          inputMask: "99/99/9999 99:99:99"
          validator: DateTimeValidator



          In C++:



          // datetimevalidator.h
          #include <QValidator>
          #include <QDateTime>

          class DateTimeValidator: public QValidator

          public:
          DateTimeValidator();

          State validate(QString& input, int& pos) const;
          ;


          // datetimevalidator.cpp
          #include <datetimevalidator.h>
          DateTimeValidator::DateTimeValidator(): QValidator()


          QValidator::State DateTimeValidator::validate(QString& input, int& pos) const

          QDateTime dt = QDateTime::fromString(input, "MM/dd/yyyy HH:mm:ss");
          if (dt.isNull()) // If null, the input cannot be parsed

          return QValidator::Invalid;

          return QValidator::Acceptable;



          In the main(), register your validator to be able to use it in QML:



          #include "datetimevalidator.h"

          int main(int argc, char** argv)

          QApplication app(argc, argv);
          qmlRegisterType<DateTimeValidator>("my.components", 1, 0, "DateTimeValidator");
          ...






          share|improve this answer



























          • Hello, i could not make this work, created a qt quick application project and added QML file with the same content, created a c++ class file with the name DateTimeValidator and added the content, registered as you suggested, but it is throwing many errors..can you please help

            – Techiesoft
            Apr 27 at 10:40











          • What's the exact errors messages?

            – Romha Korev
            Apr 27 at 11:34











          • expected class name, Unknown type name 'State' Should i create C++ class file or C++ Source file? Thanks for jumping in again

            – Techiesoft
            Apr 27 at 11:37











          • Add #include <QValidator>. Create a header file (.h). You can move the implementation in a source file, if you want.

            – Romha Korev
            Apr 27 at 12:57











          • Can you please edit your answer and include the necessary things

            – Techiesoft
            Apr 27 at 13:10










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55377770%2fdatetimeedit-in-qml-like-in-qtwidgets%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          There is no equivalent in QML. But, you can easily create your own widget with a TextField and a custom validator:



          In QML:



          TextField 
          text : "01/01/1970 00:00:00"
          inputMask: "99/99/9999 99:99:99"
          validator: DateTimeValidator



          In C++:



          // datetimevalidator.h
          #include <QValidator>
          #include <QDateTime>

          class DateTimeValidator: public QValidator

          public:
          DateTimeValidator();

          State validate(QString& input, int& pos) const;
          ;


          // datetimevalidator.cpp
          #include <datetimevalidator.h>
          DateTimeValidator::DateTimeValidator(): QValidator()


          QValidator::State DateTimeValidator::validate(QString& input, int& pos) const

          QDateTime dt = QDateTime::fromString(input, "MM/dd/yyyy HH:mm:ss");
          if (dt.isNull()) // If null, the input cannot be parsed

          return QValidator::Invalid;

          return QValidator::Acceptable;



          In the main(), register your validator to be able to use it in QML:



          #include "datetimevalidator.h"

          int main(int argc, char** argv)

          QApplication app(argc, argv);
          qmlRegisterType<DateTimeValidator>("my.components", 1, 0, "DateTimeValidator");
          ...






          share|improve this answer



























          • Hello, i could not make this work, created a qt quick application project and added QML file with the same content, created a c++ class file with the name DateTimeValidator and added the content, registered as you suggested, but it is throwing many errors..can you please help

            – Techiesoft
            Apr 27 at 10:40











          • What's the exact errors messages?

            – Romha Korev
            Apr 27 at 11:34











          • expected class name, Unknown type name 'State' Should i create C++ class file or C++ Source file? Thanks for jumping in again

            – Techiesoft
            Apr 27 at 11:37











          • Add #include <QValidator>. Create a header file (.h). You can move the implementation in a source file, if you want.

            – Romha Korev
            Apr 27 at 12:57











          • Can you please edit your answer and include the necessary things

            – Techiesoft
            Apr 27 at 13:10















          1














          There is no equivalent in QML. But, you can easily create your own widget with a TextField and a custom validator:



          In QML:



          TextField 
          text : "01/01/1970 00:00:00"
          inputMask: "99/99/9999 99:99:99"
          validator: DateTimeValidator



          In C++:



          // datetimevalidator.h
          #include <QValidator>
          #include <QDateTime>

          class DateTimeValidator: public QValidator

          public:
          DateTimeValidator();

          State validate(QString& input, int& pos) const;
          ;


          // datetimevalidator.cpp
          #include <datetimevalidator.h>
          DateTimeValidator::DateTimeValidator(): QValidator()


          QValidator::State DateTimeValidator::validate(QString& input, int& pos) const

          QDateTime dt = QDateTime::fromString(input, "MM/dd/yyyy HH:mm:ss");
          if (dt.isNull()) // If null, the input cannot be parsed

          return QValidator::Invalid;

          return QValidator::Acceptable;



          In the main(), register your validator to be able to use it in QML:



          #include "datetimevalidator.h"

          int main(int argc, char** argv)

          QApplication app(argc, argv);
          qmlRegisterType<DateTimeValidator>("my.components", 1, 0, "DateTimeValidator");
          ...






          share|improve this answer



























          • Hello, i could not make this work, created a qt quick application project and added QML file with the same content, created a c++ class file with the name DateTimeValidator and added the content, registered as you suggested, but it is throwing many errors..can you please help

            – Techiesoft
            Apr 27 at 10:40











          • What's the exact errors messages?

            – Romha Korev
            Apr 27 at 11:34











          • expected class name, Unknown type name 'State' Should i create C++ class file or C++ Source file? Thanks for jumping in again

            – Techiesoft
            Apr 27 at 11:37











          • Add #include <QValidator>. Create a header file (.h). You can move the implementation in a source file, if you want.

            – Romha Korev
            Apr 27 at 12:57











          • Can you please edit your answer and include the necessary things

            – Techiesoft
            Apr 27 at 13:10













          1












          1








          1







          There is no equivalent in QML. But, you can easily create your own widget with a TextField and a custom validator:



          In QML:



          TextField 
          text : "01/01/1970 00:00:00"
          inputMask: "99/99/9999 99:99:99"
          validator: DateTimeValidator



          In C++:



          // datetimevalidator.h
          #include <QValidator>
          #include <QDateTime>

          class DateTimeValidator: public QValidator

          public:
          DateTimeValidator();

          State validate(QString& input, int& pos) const;
          ;


          // datetimevalidator.cpp
          #include <datetimevalidator.h>
          DateTimeValidator::DateTimeValidator(): QValidator()


          QValidator::State DateTimeValidator::validate(QString& input, int& pos) const

          QDateTime dt = QDateTime::fromString(input, "MM/dd/yyyy HH:mm:ss");
          if (dt.isNull()) // If null, the input cannot be parsed

          return QValidator::Invalid;

          return QValidator::Acceptable;



          In the main(), register your validator to be able to use it in QML:



          #include "datetimevalidator.h"

          int main(int argc, char** argv)

          QApplication app(argc, argv);
          qmlRegisterType<DateTimeValidator>("my.components", 1, 0, "DateTimeValidator");
          ...






          share|improve this answer















          There is no equivalent in QML. But, you can easily create your own widget with a TextField and a custom validator:



          In QML:



          TextField 
          text : "01/01/1970 00:00:00"
          inputMask: "99/99/9999 99:99:99"
          validator: DateTimeValidator



          In C++:



          // datetimevalidator.h
          #include <QValidator>
          #include <QDateTime>

          class DateTimeValidator: public QValidator

          public:
          DateTimeValidator();

          State validate(QString& input, int& pos) const;
          ;


          // datetimevalidator.cpp
          #include <datetimevalidator.h>
          DateTimeValidator::DateTimeValidator(): QValidator()


          QValidator::State DateTimeValidator::validate(QString& input, int& pos) const

          QDateTime dt = QDateTime::fromString(input, "MM/dd/yyyy HH:mm:ss");
          if (dt.isNull()) // If null, the input cannot be parsed

          return QValidator::Invalid;

          return QValidator::Acceptable;



          In the main(), register your validator to be able to use it in QML:



          #include "datetimevalidator.h"

          int main(int argc, char** argv)

          QApplication app(argc, argv);
          qmlRegisterType<DateTimeValidator>("my.components", 1, 0, "DateTimeValidator");
          ...







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Apr 27 at 13:58

























          answered Mar 27 at 20:47









          Romha KorevRomha Korev

          4,5252 gold badges16 silver badges28 bronze badges




          4,5252 gold badges16 silver badges28 bronze badges















          • Hello, i could not make this work, created a qt quick application project and added QML file with the same content, created a c++ class file with the name DateTimeValidator and added the content, registered as you suggested, but it is throwing many errors..can you please help

            – Techiesoft
            Apr 27 at 10:40











          • What's the exact errors messages?

            – Romha Korev
            Apr 27 at 11:34











          • expected class name, Unknown type name 'State' Should i create C++ class file or C++ Source file? Thanks for jumping in again

            – Techiesoft
            Apr 27 at 11:37











          • Add #include <QValidator>. Create a header file (.h). You can move the implementation in a source file, if you want.

            – Romha Korev
            Apr 27 at 12:57











          • Can you please edit your answer and include the necessary things

            – Techiesoft
            Apr 27 at 13:10

















          • Hello, i could not make this work, created a qt quick application project and added QML file with the same content, created a c++ class file with the name DateTimeValidator and added the content, registered as you suggested, but it is throwing many errors..can you please help

            – Techiesoft
            Apr 27 at 10:40











          • What's the exact errors messages?

            – Romha Korev
            Apr 27 at 11:34











          • expected class name, Unknown type name 'State' Should i create C++ class file or C++ Source file? Thanks for jumping in again

            – Techiesoft
            Apr 27 at 11:37











          • Add #include <QValidator>. Create a header file (.h). You can move the implementation in a source file, if you want.

            – Romha Korev
            Apr 27 at 12:57











          • Can you please edit your answer and include the necessary things

            – Techiesoft
            Apr 27 at 13:10
















          Hello, i could not make this work, created a qt quick application project and added QML file with the same content, created a c++ class file with the name DateTimeValidator and added the content, registered as you suggested, but it is throwing many errors..can you please help

          – Techiesoft
          Apr 27 at 10:40





          Hello, i could not make this work, created a qt quick application project and added QML file with the same content, created a c++ class file with the name DateTimeValidator and added the content, registered as you suggested, but it is throwing many errors..can you please help

          – Techiesoft
          Apr 27 at 10:40













          What's the exact errors messages?

          – Romha Korev
          Apr 27 at 11:34





          What's the exact errors messages?

          – Romha Korev
          Apr 27 at 11:34













          expected class name, Unknown type name 'State' Should i create C++ class file or C++ Source file? Thanks for jumping in again

          – Techiesoft
          Apr 27 at 11:37





          expected class name, Unknown type name 'State' Should i create C++ class file or C++ Source file? Thanks for jumping in again

          – Techiesoft
          Apr 27 at 11:37













          Add #include <QValidator>. Create a header file (.h). You can move the implementation in a source file, if you want.

          – Romha Korev
          Apr 27 at 12:57





          Add #include <QValidator>. Create a header file (.h). You can move the implementation in a source file, if you want.

          – Romha Korev
          Apr 27 at 12:57













          Can you please edit your answer and include the necessary things

          – Techiesoft
          Apr 27 at 13:10





          Can you please edit your answer and include the necessary things

          – Techiesoft
          Apr 27 at 13:10








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55377770%2fdatetimeedit-in-qml-like-in-qtwidgets%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해