1

I am developing a Qt CLI application. I know that we should only use the class of CORE lib

QT       -= gui
CONFIG   += console

But I want to use QStandardItemModel for a tree view (show on console window). How about if I set Qt += gui and include QStandardItemModel in my code and develop a CLI application.

P/s: Could I create a standard tree model for developing both GUI and CLI application instead of QStandardItemModel (only work on GUI)?

AAEM
  • 1,837
  • 2
  • 18
  • 26
kien bui
  • 1,760
  • 2
  • 17
  • 33
  • I think you can sub class the `QAbstractItemModel` and use it without linking to QtGui module, as `QAbstractItemModel` is in QtCore and independent from GUI. – vahancho Nov 13 '18 at 08:34
  • How about if I set Qt += gui and include QStandardItemModel in my code and develop a CLI application? What problem or conflict? – kien bui Nov 13 '18 at 08:36
  • I can set QT += GUI But I am not sure that what problem or conflict when I set GUI for CLI app. – kien bui Nov 13 '18 at 08:40
  • You can easily add `QT += gui` without any problems and continue to use a `QCoreApplication`, as long as you do not use any class that might show anything GUI-related. If you ever do accidentily, Qt will print a warning and not just crash, so it's pretty safe to use that way – Felix Nov 13 '18 at 09:59

0 Answers0