2

I Wrote before but the details was not explained. I explain step by step what I do;

  1. Witty installation Guide Ubuntu

    I did in order what ever said in this page.

    sudo apt-get install gcc g++ libboost-all-dev cmake make sudo apt-get install libssl-dev libfcgi-dev sudo apt-get install libpq-dev libmysqlclient-dev firebird-dev sudo apt-get install libpng12-dev libgraphicsmagick1-dev libhpdf-dev libpng12-dev libpango1.0-dev mesa-common-dev sudo apt-get install asciidoc libqt4-dev sudo apt-get install doxygen graphviz

    wget -c http://kent.dl.sourceforge.net/sourceforge/witty/wt-3.3.4.tar.gz tar xvxf wt-3.3.4.tar.gz

    cd wt-3.3.4 mkdir build cd build cmake .. make make -C examples

and Test helloqt.wt test

./helloqt.wt --http-port 10000 --http-addr 0.0.0.0 --docroot .

Every things work fine

and then I changed someline for Qt events loop working

// Needed when using WQApplication with Qt eventloop = true
#include <QApplication>

Dictionary::Dictionary(const WEnvironment& env)
  : WQApplication(env , true )
{
  /*
   * Note: do not create any Qt objects from here. Initialize your
   * application from within the virtual create() method.
   */
}

.
.
.
int main(int argc, char **argv)
{
  // Needed for Qt's eventloop threads to work
  QApplication app(argc, argv);

  return WRun(argc, argv, &createApplication);
}

still result is fine everything OK. eventloops( signal/slot working )

and I clean everything with

make clean

add line to cmakefiles.txt QtNetwork

.
.
.
IF(ENABLE_QT4)
  FIND_PACKAGE(Qt4 REQUIRED QtCore QtGui QtNetwork)

  IF(QT_FOUND)
    INCLUDE(${QT_USE_FILE})
  ENDIF(QT_FOUND)
ENDIF(ENABLE_QT4)
.
.
.

and also add to wtwithqt examples cmakelist.txt ${QT_QTNETWORK_LIBRARY}

  FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtNetwork )

  SET(QT_USE_QTNETWORK true)

  INCLUDE(${QT_USE_FILE})

to below

IF(COMMAND cmake_policy)
  CMAKE_POLICY(SET CMP0003 NEW)
ENDIF(COMMAND cmake_policy)

SET(BUILD_WTWITHQT true)
IF (NOT MULTI_THREADED_BUILD)
  SET(BUILD_WTWITHQT false)
ENDIF (NOT MULTI_THREADED_BUILD)
IF (NOT QT_FOUND)
  SET(BUILD_WTWITHQT false)
ENDIF (NOT QT_FOUND)

IF (NOT BUILD_WTWITHQT)

  MESSAGE(STATUS "** Not building wtwithqt example.")
  MESSAGE(STATUS "   wtwithqt example requires a Qt4 installation.")

ELSE (NOT BUILD_WTWITHQT)




  MESSAGE("\n\n " + ${QT_QTCORE_LIBRARY} + " \n" + ${QT_QTGUI_LIBRARY} + "\n" +  ${QT_QTNETWORK_LIBRARY} + "\n" +    ${QT_LIBRARIES}  + "\n\n" )

  FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtNetwork )

  SET(QT_USE_QTNETWORK true)

  INCLUDE(${QT_USE_FILE})

  SUBDIRS(lib)

  ADD_DEFINITIONS(-DWT_NO_SLOT_MACROS)

  QT4_GENERATE_MOC(${CMAKE_CURRENT_SOURCE_DIR}/QtObject.h
                   ${CMAKE_CURRENT_BINARY_DIR}/moccedQtObject.C)

  WT_ADD_EXAMPLE(helloqt.wt
    hello.C
    QtObject.C
    ${CMAKE_CURRENT_BINARY_DIR}/moccedQtObject.C
  )

  TARGET_LINK_LIBRARIES(helloqt.wt
    wtwithqt
    ${QT_QTCORE_LIBRARY}
    ${QT_QTGUI_LIBRARY}
    ${QT_QTNETWORK_LIBRARY}
    ${QT_LIBRARIES}
  )

  #
  # If you have Wt installed somehwere, you should use the
  # installed Wt header files for your own Wt projects.
  # e.g. INCLUDE_DIRECTORIES(/usr/local/wt/include)
  # instead of the following:
  #
  INCLUDE_DIRECTORIES(
    ${WT_SOURCE_DIR}/src
    ${CMAKE_CURRENT_SOURCE_DIR}/lib
    ${QT_QTCORE_INCLUDE_DIR} 
    ${QT_QTNETWORK_INCLUDE_DIR} 
    ${QT_INCLUDE_DIR}

  )

ENDIF (NOT BUILD_WTWITHQT)

and add to QTcpSocket to function below QtObject.h

// This may look like C code, but it's really -- C++ --

#ifndef QTOBJECT_H_
#define QTOBJECT_H_

#include <QThread>
#include <QTcpSocket>

class Dictionary;

/*! \class QtObject
 *  \brief A simple Qt object with sample signal and slot.
 *
 * This simple object class demonstrates that the Qt signal/slot
 * mechanism may be used alonglisde Wt's signal/slot mechanism.
 */
class QtObject : public QObject
{
  Q_OBJECT;

public:
  QtObject(Dictionary *wt_, QObject *parent = 0);

  void passGreet(const QString&);

  QTcpSocket* socket;

signals:
  void greet(const QString&);

public slots:
  void doGreet(const QString&);
  void Connected();

private:
  Dictionary *wt_;
};

#endif // QTOBJECT_H_

QtObject.C file

 #include "HelloApplication.h"
#include "QtObject.h"
#include <QHostAddress>

QtObject::QtObject(Dictionary *wt, QObject *parent)
  : QObject(parent),
    wt_(wt)
{ 

    socket = new QTcpSocket();

    QHostAddress adr;

    adr.setAddress("192.168.0.2");

    socket->connectToHost(adr,17776);


    QObject::connect(socket,SIGNAL(connected()),this,SLOT(Connected()));

}

void QtObject::passGreet(const QString& name)
{
  emit greet(name);
}

void QtObject::doGreet(const QString& name)
{
  wt_->doGreet(name);
}


void QtObject::Connected(){

    std::cout << "\n\nCONNNECTED\n\n";
    emit greet(QString("QString"));
}

From this time

cml@cml-All-Series:~/wt-3.3.4/build$ make clean
cml@cml-All-Series:~/wt-3.3.4/build$ cmake ..
cml@cml-All-Series:~/wt-3.3.4/build$ make -j8
cml@cml-All-Series:~/wt-3.3.4/build$ make -C examples/wtwithqt


cml@cml-All-Series:~/wt-3.3.4/build/examples/wtwithqt$ ./helloqt.wt charts.wt --http-port 10000 --http-addr 0.0.0.0 --docroot .
[2015-Aug-22 10:34:04.692004] 3116 - [info] "WServer/wthttp: initializing built-in wthttpd"
[2015-Aug-22 10:34:04.693292] 3116 - [info] "wthttp: started server: http://0.0.0.0:10000"

when click on browser 0.0.0.0:10000 page is incoming and

socket emitting Connected() signals and Connected() SLOT Work

print screen to std::cout << "\n\nCONNNECTED\n\n";

and application

crashed. Segmentation fault and Core Dumped

I can not find what is wrong?

I Debug Qt Creator

WWebWidget.C file stopped there

    bool WWebWidget::canOptimizeUpdates()
    {
->      return WApplication::instance()->session()->renderer().preLearning();
    }

Qt Creator Debugger says ->

The inferior stopped because it received a signal from the Operating System.

Signal name : 
SIGSEGV
Signal meaning : 
Segmentation fault

2 Answers2

0

There talking about the solution

in my code I delete WText object after there is no fail seg fault...

this is not solution for me but I can use it

0
Wt::WApplication* app = Wt::WApplication::instance();

app->enableUpdates(true);

Wt::WApplication::UpdateLock uilock(app);


if( uilock ){
   button->setText("Test"); //Here is Editable Widget
   app->trigerUpdate(); 
   app->enableUpdates(false);
}

For a big work you lock application and

control if locked change any thing ServerPUSH.c

CMLDMR
  • 334
  • 2
  • 12