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. [solved]class doesn't name a type
Forum Updated to NodeBB v4.3 + New Features

[solved]class doesn't name a type

Scheduled Pinned Locked Moved General and Desktop
9 Posts 4 Posters 4.4k 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.
  • M Offline
    M Offline
    mehdi.nine
    wrote on last edited by
    #1

    Hi, I have to class, USB and MainForm.
    in USB class i want to have an object of Mainform class but it has following error:
    @
    C:\Users(Mahdi)\Documents\QT\untitled1\usb.h:28: error: 'MainForm' does not name a type
    @
    this is USB.h
    @
    #include "mainform.h"
    using namespace std;
    class USB:public QThread
    {

    private:

    int Digital_Packet_Count;
    int Analog_Packet_Count;
    int TAkhasosi_Packet_Count;
    ContentControl *Temp_Content;
    MainForm *m;
    .
    .
    .
    @
    this is MainForm class:
    @
    namespace Ui {
    class MainForm;
    }

    class MainForm : public QWidget
    {
    Q_OBJECT

    public:

    QList<QWidget*> All_Images;
    QList<QMovie*> All_Gif;
    explicit MainForm(QWidget *parent = 0);
    ~MainForm();
    

    @
    what is problem?(ContentControl is another class that i have an object from it in USB class but it has no problem)

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      Try
      @
      Ui::MainForm *m;
      @

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mehdi.nine
        wrote on last edited by
        #3

        i did it but has following error:
        @
        C:\Users(Mahdi)\Documents\QT\untitled1\usb.h:22: error: 'MainForm' in namespace 'Ui' does not name a type
        @

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dbzhang800
          wrote on last edited by
          #4

          Hi, note that, QWidget and subclass of it can only be used main thread.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mehdi.nine
            wrote on last edited by
            #5

            Hi, can you explain more?

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

              Hi,

              Short version: QWidget and QWidget based classes can only be used from the GUI thread. The one that is started when you call app.exec();

              You can't create and use widgets from other threads

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

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mehdi.nine
                wrote on last edited by
                #7

                thanks. so i can't use from MainForm Object in USB class any way?

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

                  No,

                  You should have your class USB do all the handling it needs to do (I suppose it's low level stuff), give it an interface where you can connect a GUI on it and keep the two things separated.

                  It will make your design cleaner keeping either responsibilities separated

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

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mehdi.nine
                    wrote on last edited by
                    #9

                    thanks for all replies.
                    i found the problem. i MainForm class i include usb.h and in usb.h i include MainForm.h. when i delete usb.h from MainForm problem has solved.

                    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