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. I hope that you help me
Forum Updated to NodeBB v4.3 + New Features

I hope that you help me

Scheduled Pinned Locked Moved General and Desktop
12 Posts 3 Posters 2.9k 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.
  • Y Offline
    Y Offline
    yakine
    wrote on last edited by
    #1

    hello
    can any one help me please
    this is my code iwant to create a button that when it clicked an html file open

    @#include<QApplication>

    include<QObject>

    #include <QTwidjets>
    #include<QDesktopServices>
    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);

    QPushButton bouton;
    QString link ="C:/Users/kouki/Desktop/versement.html";

    QObject::connect(&bouton,SIGNAL(clicked()),&link,SLOT(QDesktopServices::openUrl(QUrl(link))));
    bouton.show();

    return app.exec();
    }@
    and this is the error
    C:\Users\kouki\qtprojects\tesehtml\main.cpp:19: erreur : C2665: 'QObject::connect'ÿ: aucune des 3 surcharges n'a pu convertir tous les types d'arguments
    c:\qt\qt5.2.1\5.2.1\msvc2012_64_opengl\include\qtcore\qobject.h(198): peut ˆtre 'QMetaObject::Connection QObject::connect(const QObject *,const char *,const QObject *,const char *,Qt::ConnectionType)'
    c:\qt\qt5.2.1\5.2.1\msvc2012_64_opengl\include\qtcore\qobject.h(201): ou 'QMetaObject::Connection QObject::connect(const QObject *,const QMetaMethod &,const QObject *,const QMetaMethod &,Qt::ConnectionType)'
    c:\qt\qt5.2.1\5.2.1\msvc2012_64_opengl\include\qtcore\qobject.h(205): ou 'QMetaObject::Connection QObject::connect(const QObject *,const char *,const char *,Qt::ConnectionType) const'
    lors de la tentative de mise en correspondance de la liste des arguments '(QPushButton *, const char *, QString *, const char *)'
    thank you in advance

    IF YOU HAVE MERCY ON PEOPLE GOD HAVE MERCY ON YOU

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      Hi,
      My French is terrible, so no idea what your error codes tell me, besides your made a signal/slot error.
      The Signal/slot connection you created is wrong.
      The openUrl is a static member function, not a slot!
      So in a class generate a slot, in that slot, call the static openUrl function.
      The second mistake in your signal/slot is that both signal and slots need to have the same arguments!
      Read this article please:
      "Signals explained":https://qt-project.org/doc/qt-5.0/qtcore/signalsandslots.html

      Greetz, Jeroen

      1 Reply Last reply
      0
      • EddyE Offline
        EddyE Offline
        Eddy
        wrote on last edited by
        #3

        Hi Yakine,

        I advice you to read/understand the following :"getting started guide" http://qt-project.org/doc/qt-5/gettingstartedqt.html

        I adapted it a little to your likings below.

        Try the following approach :
        make a new project using widgets and choose QMainwindow. (or QDialog, but then you get other names and stuff...)

        adapt the ui file and add a QPushButton to it using Qt Creator. Keep the default name for it : pushButton.

        then alter the following files :
        mainwindow.h
        @
        #ifndef MAINWINDOW_H
        #define MAINWINDOW_H

        #include <QMainWindow>

        namespace Ui {
        class MainWindow;
        }

        class MainWindow : public QMainWindow
        {
        Q_OBJECT

        public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();

        public slots:
        void openHTML(); //ADD THIS LINE

        private:
        Ui::MainWindow *ui;
        };

        #endif // MAINWINDOW_H
        @
        mainwindow.cpp
        @
        #include "mainwindow.h"
        #include "ui_mainwindow.h"
        #include <qdesktopservices.h>
        #include <QUrl>
        #include <QObject>

        MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
        {
        ui->setupUi(this);

          //ADD THIS LINE
        connect(ui->pushButton, SIGNAL(clicked()), this,  SLOT(openHTML()));
        //or
        //connect(ui->pushButton, SIGNAL(clicked()),  this, SLOT(openHTML()));
        

        }

        MainWindow::~MainWindow()
        {
        delete ui;
        }

          //ADD THIS SLOT
        

        void MainWindow::openHTML()
        {
        QDesktopServices::openUrl(QUrl("file:///C:/QtProject.htm"));
        }
        @

        Feel free to ask here if you have any doubts.

        Qt Certified Specialist
        www.edalsolutions.be

        1 Reply Last reply
        0
        • Y Offline
          Y Offline
          yakine
          wrote on last edited by
          #4

          koukou

          thank you both but Eddy i want that you knew that i have created an empty project am programing evry thing with qt creator i don't use the qt design i tryed what you suggest and it work's but it's not what i need if you can help please and sorry about my English

          IF YOU HAVE MERCY ON PEOPLE GOD HAVE MERCY ON YOU

          1 Reply Last reply
          0
          • Y Offline
            Y Offline
            yakine
            wrote on last edited by
            #5

            if you can tell me what slot i supposed to use ?

            IF YOU HAVE MERCY ON PEOPLE GOD HAVE MERCY ON YOU

            1 Reply Last reply
            0
            • JeroentjehomeJ Offline
              JeroentjehomeJ Offline
              Jeroentjehome
              wrote on last edited by
              #6

              @
              void MainWindow::MainWindow(QWidget * parent):
              QMainWindow(parent)
              {
              m_PushButton * = new QPushButton(this);
              m_PushButton.setText("Start URL");
              connect (m_PushButton, SIGNAL(clicked()),
              this, SLOT(OpenURLRequest()));
              }

              // --> THIS IS YOUR SLOT!!!
              void MainWindow::OpenURLRequest(void)
              {
              QDesktopServices::openUrl(QUrl("file:///C:/QtProject.htm"));
              }
              @
              In your class definition:
              @
              public slots:
              void OpenURLRequest(void);
              @

              Greetz, Jeroen

              1 Reply Last reply
              0
              • EddyE Offline
                EddyE Offline
                Eddy
                wrote on last edited by
                #7

                Hi Yakine,

                I advice you to read the book :
                "C++ GUI Programming with Qt 4"
                If you google you might find the first version which is free.

                chapter 2 explains in detail what you need (using only code and no ui file)

                Basically you make a new class, put your button in it. Put it in a QLayout. Add a slot and connect to that slot. I already gave you 2 connect statements.

                here is another example :
                "Basic Layout Example":http://qt-project.org/doc/qt-4.8/layouts-basiclayouts.html

                Hope this helps

                Qt Certified Specialist
                www.edalsolutions.be

                1 Reply Last reply
                0
                • Y Offline
                  Y Offline
                  yakine
                  wrote on last edited by
                  #8

                  am terrible i knew but sorry look i don't use poo i don't crate classes
                  all that i do it's crating an empty project with contain a main.cpp
                  in this main i creat my window
                  @QWidget window ;@

                  then i crate a qpushbutton like this

                  @QPushbutton button("open",&window);@

                  and when user clicked on this button an html file wich i created and i saved on my desktop open but how can i connect btween the button that i created and the html file

                  IF YOU HAVE MERCY ON PEOPLE GOD HAVE MERCY ON YOU

                  1 Reply Last reply
                  0
                  • EddyE Offline
                    EddyE Offline
                    Eddy
                    wrote on last edited by
                    #9

                    Your "window" doesn't have a slot that calls openUrl.

                    That's why you have to make a derived class and define a custom slot yourself, as we showed you.

                    Please read the links we gave you, they will help you understand

                    Qt Certified Specialist
                    www.edalsolutions.be

                    1 Reply Last reply
                    0
                    • Y Offline
                      Y Offline
                      yakine
                      wrote on last edited by
                      #10

                      thank you a lot Eddy am reading what you suggest and when i finished i will try to do it . thank you so much you are great person
                      i have a little request if you have any suggest or any tuto that can help me to realise a managment application for a medical office with qt Creator thank you again

                      IF YOU HAVE MERCY ON PEOPLE GOD HAVE MERCY ON YOU

                      1 Reply Last reply
                      0
                      • EddyE Offline
                        EddyE Offline
                        Eddy
                        wrote on last edited by
                        #11

                        Thanks,

                        I can't help you with your new question. I suggest you start a new topic and be specific about what you want. Your question is too general.

                        Qt Certified Specialist
                        www.edalsolutions.be

                        1 Reply Last reply
                        0
                        • Y Offline
                          Y Offline
                          yakine
                          wrote on last edited by
                          #12

                          ok thank's have a good day

                          IF YOU HAVE MERCY ON PEOPLE GOD HAVE MERCY ON YOU

                          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